数据插入数据库php时通知我 [英] notify me when data inserted in database php
本文介绍了数据插入数据库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...
这篇关于数据插入数据库php时通知我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文