MySql查询 - 语法错误

时间:2014-05-27 14:41:48

标签: php mysql

以下代码是我在PHP中使用的SQL查询。

$sql = "INSERT INTO updates (update,user_id_fk) 
VALUES ('$post_update','$username')";

它不起作用 - 运行时收到以下错误消息。

Error: 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 'update,user_id_fk)

这种语法对我来说很好 - 它和我在W3Schools上发现的一样。

我使用的mysql版本是5.5.24

1 个答案:

答案 0 :(得分:5)

update是一个保留的关键字反引号

INSERT INTO updates (`update`,user_id_fk) 

检查下面的列表,将来不要将这些字用于您的表名或列名

http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

相关问题