<分区>
我正在尝试使用 PHP 的“INSERT INTO”函数,但由于某些未知原因,它无法正常工作。
这是代码的主要部分 -
$sql = "INSERT INTO order (t_from, t_to, t_date, t_time, t_payment, t_sn, t_u_email)
VALUES ('a', 'b', 'c', 'd', 'e', 'f', 'g')";
这有什么问题吗?
请帮忙!
谢谢,
<分区>
我正在尝试使用 PHP 的“INSERT INTO”函数,但由于某些未知原因,它无法正常工作。
这是代码的主要部分 -
$sql = "INSERT INTO order (t_from, t_to, t_date, t_time, t_payment, t_sn, t_u_email)
VALUES ('a', 'b', 'c', 'd', 'e', 'f', 'g')";
这有什么问题吗?
请帮忙!
谢谢,
最佳答案
order
是 MySQL 的保留关键字。
http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-0.html
要么将 order
更改为其他内容,
或者在 order
周围加上反引号。
$sql = "INSERT INTO `order` (t_from, t_to, t_date, t_time, t_payment, t_sn, t_u_email)
VALUES ('a', 'b', 'c', 'd', 'e', 'f', 'g')";
另一种解决方案是在表名之前使用数据库名。
$sql = "INSERT INTO DB_NAME.order (t_from, t_to, t_date, t_time, t_payment, t_sn, t_u_email)
VALUES ('a', 'b', 'c', 'd', 'e', 'f', 'g')";
关于PHP "INSERT INTO"不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27104224/