执行此php代码时出现一些错误:
$today = date("Y-m-d H:i:s");
$sql = "UPDATE `deposit_admin_report` SET `READING`=$item,`Timestamp`=$today WHERE `METER_NUMBER`='NP-1353-'";
错误:
UPDATE `deposit_admin_report` SET `READING`=395,`Timestamp`=2015-11-27 09:08:33 WHERE `METER_NUMBER`='NP-1353-'
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '09:08:33 WHERE `METER_NUMBER`='NP-1353-'' at line 1
列Timestamp在mysql表中的类型为“ timestamp”,默认值为“ null”。
如果有人可以帮助我,将不胜感激。
提前致谢
这是您需要的:
$today = date("Y-m-d H:i:s");
$sql = "UPDATE `deposit_admin_report` SET `READING`=$item,`Timestamp`='".$today."' WHERE `METER_NUMBER`='NP-1353-'";
还有另一种方法:
只需使用NOW()
像这样:
$ sql =“ UPDATE deposit_admin_report
SET READING
='$ item',Timestamp
= NOW()WHERE METER_NUMBER
='NP-1353-'”;
而已 :)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句