此调用失败并出现错误:
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'
- 我有一个名为“check”的表,其中包含适量的字段
- 如果我将表名称更改为
checkSomething
它有效...
有什么想法吗?
最佳答案
check
是保留关键字。要将其用作表名,您必须使用反引号对其进行转义,如下所示:`check`
:
$stmt = $mysqli->prepare("INSERT INTO `check` VALUES (?,?,?,?,?,?)");
关于当表名是 "check"时,PHP $mysqli->prepare 出现奇怪语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19825096/