数据插入数据库php时通知我
问题描述:
if (($address == "") AND ( $date == "")) {
echo "";
} else {
date_default_timezone_set('Etc/GMT+8');
$sent_dt = date('Y-m-d H:i:s');
$sql = "INSERT INTO info (address,date) VALUES (:phone,:date)";
$q = $CNT->prepare($sql);
$q->execute(
array(
':address' => "$address",
':date' => "$sent_dt"
)
);
}
我想将此脚本放到其他地方,以便每次有新的
I want to put this script inside else so that every time there is a new data inserted it will notify me.
echo'<script>
Push.create("Hello from the other side!", {
body: "You're invited",
icon: "img/k.jpg",
timeout: 4000,
onClick: function () {
window.focus();
this.close();
}
});
</script>';
答
检查语句execute是否返回true或false:
Check if the statement execute returns true or false:
if($q->execute(array(':address'=>"$address",':date'=>"$sent_dt"))==TRUE) {
echo ' <script>Push.create("Hello from the other side!", { body: "You\'re invited", icon: "img/k.jpg", timeout: 4000, onClick: function () { window.focus(); this.close(); }`` });</script> ';
}
哦,我们必须转义字符...
Oh by the way we have to escape characters...