我是 PHP 和 SQL 的新手,但我正在创建一个登录系统。我遇到的问题是:
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 'Surname typed in')' at line 5
所以我查看了代码,我相信它指的是:
mysql_query("INSERT INTO users (email, password, hash, forename, surname) VALUES(
'". mysql_escape_string($email) ."',
'". mysql_escape_string($password) ."',
'". mysql_escape_string($hash) ."',
'". mysql_escape_string($forename) .",
'". mysql_escape_string($surname) ."') ") or die(mysql_error());
看了看,没看出语法错误。有人发现了吗?
最佳答案
在这一行:
'". mysql_escape_string($forename) .",
// ^--- no closing single quote here.
您忘记了结束引号。
关于PHP 引发 SQL 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15047048/