MySQL错误:您的SQL语法有错误;请查看与MySQL服务器版本对应的手册,以获取附近要使用的正确语法


MySQL error: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

错误:

您的SQL语法有错误;查看与MySQL服务器版本相对应的手册,了解在第1行"WHERE username=32112附近使用的正确语法

PHP代码:

mysql_query ("SELECT * FROM '$iAccount_table' WHERE username=$user") or die(mysql_error());

在$iAccount_table变量中使用`而不是'。正因为如此,它才出错。

更新:

mysql_query("SELECT*FROM`$iAccount_table`WHERE username=$user")或die(mysql_error());

我假设"username"是数据库中的一个text/char字段。试试这个代码:

mysql_query ("SELECT * FROM " . $iAccount_table . " WHERE username='" . $user . "'") or die(mysql_error());

我希望你觉得这很有帮助。

更改

mysql_query ("SELECT * FROM '$iAccount_table' WHERE username=$user") or die(mysql_error());

mysql_query ("SELECT * FROM `$iAccount_table` WHERE username=$user") or die(mysql_error());

希望这能有所帮助。

使用反引号(重音符)`而不是单引号,这样

"SELECT * FROM `$iAccount_table` WHERE username=$user"