当我运行我编写的一些 php 代码时,我收到以下消息:
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 'condition, price, name, email) VALUES('Fake Title', 'Fake Subhead', 'Fake Author' at line 1
不过,我没有发现我的语法有任何问题,就像:
mysql_query("INSERT INTO table (x1, x2, x3) VALUES('$y1', '$y2', '$y3')");
最佳答案
condition 不允许作为列名(它是保留关键字),您需要用反引号 (`) 将其引用以“绕过”:
INSERT INTO table_name(`condition`、price、name、email)VALUES (...)
查看更多信息:http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
关于php - 奇怪的 PHP 错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4930565/