gpt4 book ai didi

php - 无法使此 MySQL 查询正常工作

转载 作者:行者123 更新时间:2023-12-01 00:01:26 25 4
gpt4 key购买 nike

得到这个查询:

mysql_query("INSERT INTO leaderboard (user_id, lines) 
VALUES (". $rowUser['id'] .",". $linesDone .")") or die("ERROR 29: ". mysql_error());

给出这个错误:

ERROR 29: 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 'lines) VALUES (1,50)' at line 1

我已经尝试了所有类型的语法,例如在查询中使用 ´´ 和 '',但所有结果大约为。同样的错误。

谁能看出哪里出了问题?

最佳答案

Lines 是 MySQL 中的保留字 - 你必须用反引号转义这个字

mysql_query("INSERT INTO leaderboard (user_id, `lines`) 
VALUES (". $rowUser['id'] .",". $linesDone .")") or die("ERROR 29: ". mysql_error());

顺便说一下,mysql_* 已弃用,如 manual 中所述.最好使用 mysqli_* 或 pdo

关于php - 无法使此 MySQL 查询正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14885544/

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