gpt4 book ai didi

php - mysql 更新查询失败

转载 作者:行者123 更新时间:2023-11-29 06:19:58 24 4
gpt4 key购买 nike

我的查询代码是:

$query = mysql_query("UPDATE books SET read = 'y' WHERE id = 2") or die(mysql_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 'read = 'y' WHERE id = 2' at line 1

最佳答案

read是MySQL中的保留关键字。将其括在反引号中:

UPDATE books SET `read` = 'y' WHERE id = '2'

参见http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html查看保留关键字列表。

关于php - mysql 更新查询失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4306935/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com