[英]Cant get this MySQL query working
Got this query: 得到了这个查询:
mysql_query("INSERT INTO leaderboard (user_id, lines)
VALUES (". $rowUser['id'] .",". $linesDone .")") or die("ERROR 29: ". mysql_error());
Giving this 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
I've tried all kind of syntaxing, like using ´´ and '' in the query, but all resulting in approx. 我已经尝试了所有类型的语法,例如在查询中使用´´和'',但是所有结果都差不多。 the same error.
同样的错误。
Can anyone see what is wrong? 谁能看到错在哪里?
Lines is a reserved word in MySQL - you have to escape this word with backticks 行是MySQL中的保留字-您必须使用反引号将其转义
mysql_query("INSERT INTO leaderboard (user_id, `lines`)
VALUES (". $rowUser['id'] .",". $linesDone .")") or die("ERROR 29: ". mysql_error());
btw.. mysql_* is deprecated as mentioned in the manual . btw .. mysql_ *已被弃用,如手册中所述。 Better use mysqli_* or pdo
最好使用mysqli_ *或pdo
Secure your query. 保护您的查询。
mysql_query(
sprintf("INSERT INTO leaderboard (user_id,`lines`)
VALUES ('%d','%s')",
mysql_real_escape_string($rowUser['id']),
mysql_real_escape_string($linesDone)
) or die("ERROR 29: ". mysql_error());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.