简体   繁体   English

MySQL查询-语法错误

[英]MySql query - syntax error

The following code is an SQL query that I am using in PHP. 以下代码是我在PHP中使用的SQL查询。

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

It does not work - I get the following error message when it is run. 它不起作用-运行时收到以下错误消息。

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)

This syntax loks fine to me - it is the same as I found on W3Schools. 这个语法对我来说很好-与W3Schools上的语法相同。

The mysql verion I am using is 5.5.24 我正在使用的mysql版本是5.5.24

update is a reserved keyword backtick it 更新是保留的关键字,请勾选它

INSERT INTO updates (`update`,user_id_fk) 

check the list below and in future do not use these words for your table or column names 检查下面的列表,以后不要在表或列名中使用这些单词

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM