【发布时间】:2023-03-12 07:50:02
【问题描述】:
我有一个名为 ORDER 的表,标题为 order_date,我需要在其中放置日期。
function NewOrderID()
{
$date = date('Y-m-d H:i:s');
$t = "INSERT INTO order (order_date)
VALUES (' ".$date." ')";
$query = sprintf($t);
$result = mysql_query($query);
if (!$result)
die(mysql_error());
return mysql_insert_id();
}
我收到以下错误:
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 'order ('order_date')
VALUES (' 2014-04-29 15:02:40 ')' at line 1
有什么想法让我搞砸了查询?
【问题讨论】:
-
订单是保留关键字使用反引号围绕`订单
-
是的,谢谢:) 我已经更改了订单 tp my_order 并且一切正常