编辑: 这个问题已经解决。它与其他内部 PHP 代码一起从 mysql 查询中删除注释。字符串中的散列“#”被视为注释起点,并且从该点开始删除查询的其余部分,从而导致格式错误的查询。但探查器仅在注释被删除之前跟踪查询。
我有这个 MySQL 查询:
INSERT INTO sacrifice_users
(user_primary_role_id, user_password_salt, user_date_password_updated, user_password, user_login, user_visible_name, user_visible_name_urlsafe, user_firstname, user_lastname, user_email, user_date_created, user_status, user_date_edited)
VALUES
(6,'0(_!f\"}O:r1=Fsvb:Xb|0DG3S/gu&9K}/*5)7[2?30|V7+5<0;!f#)9o;bBc}@*/c\"q-@:8a{)0iY5?}5H7>550]QpS8Y[v(n@2|07)x-|-+-8242w?#4&+@/X:8,8Su','2011-02-02 15:02:18','MVYMGgXFqhM0grGWff9gctr2XPYhGD58IwBQ/aVITNbC9+odsm0eyF+fmyzb4qfes/Ij8hvY9yRVA3PZWzpxbMp8G43DgUhvYOUjqRYeHHfMcYPr7Uihh1hfAKQLS627','Admin','Admin','Admin','Admin','Admin','no-reply@xxx.co.uk','2011-02-02 15:02:18','confirmed','2011-02-02 15:02:18')
它在 PHP 中从 MySQL 中抛出一个错误
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 ''0(_!f\"}O:r1=Fsvb:Xb|0DG3S/gu&9K}/5)7[2?30|V7+5<0;!f#)9o;bBc}@/c\"q-@:8a{)0iY' at line 4
但是通过命令行运行查询运行良好。有人知道为什么会这样吗?
最佳答案
我看到了特殊字符。你可以尝试使用 mysql_real_escape_string排除这种可能性?
关于php - MySQL 查询错误,在 PHP 中抛出但在终端中正常。任何解释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4876206/