prepare 出现奇怪语法错误-6ren"> prepare 出现奇怪语法错误-这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭-6ren">
gpt4 book ai didi

当表名是 "check"时,PHP $mysqli->prepare 出现奇怪语法错误

转载 作者:行者123 更新时间:2023-12-02 21:44:07 25 4
gpt4 key购买 nike

此调用失败并出现错误:

mysqli_report(MYSQLI_REPORT_ALL);
$stmt = $mysqli->prepare("INSERT INTO check VALUES (?,?,?,?,?,?)");

我得到的错误:

Uncaught exception 'mysqli_sql_exception' with message '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 'check VALUES (?,?,?,?,?,?)' at line 1'

  1. 我有一个名为“check”的表,其中包含适量的字段
  2. 如果我将表名称更改为 checkSomething它有效...

有什么想法吗?

最佳答案

check 是保留关键字。要将其用作表名,您必须使用反引号对其进行转义,如下所示:`check` :

$stmt = $mysqli->prepare("INSERT INTO `check` VALUES (?,?,?,?,?,?)");

关于当表名是 "check"时,PHP $mysqli->prepare 出现奇怪语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19825096/

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