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 '('RealName') VALUES ('Louise T') WHERE SteamID='7656119801402xxxx'' at line 1
$mysql_hostname = "localhost";
$mysql_user = "xxxx";
$mysql_password = "xxxx";
$mysql_database = "xxxx";
$prefix = "";
$conn = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
$connect = mysql_select_db($mysql_database, $conn);
$realname = 'Louise T';
$steamid = '7656119801402xxxx';
$sql="UPDATE users SET ('RealName') VALUES ('". mysql_real_escape_string($realname) ."') WHERE SteamID='$steamid'";
if (!mysql_query($sql))
{
die('Error: ' . mysql_error());
} else {
header("Location: index.php");
exit();
}
不知道这是什么原因造成的?我一直在检查每个单词是否干扰了某些 MySQL 命令,但似乎仍然出现此错误。
这是我在网上找到的一些规则:
- 您省略或包含了不必要的符号:!@#$%^&*()-_=+[]{}|;:'",<>/?
- 放错位置、遗漏或不必要的关键字:select、into 或无数其他关键字。
- 您的查询中有看起来像 ascii 字符但无法识别的 unicode 字符。
- 关键字之间错位、缺失或不必要的空格或换行符。
- 不匹配的单引号、双引号、圆括号或大括号。
但我真的不认为有类似的东西吗?
最佳答案
您的更新查询无效,因为 SET ('RealName') VALUES
不是有效的语法 more details
像这样使用更新:-
UPDATE users SET RealName='$realname' WHERE SteamID='$steamid'
对于插入:-
Insert into users (RealName) values ('$steamid')
关于php - 错误 : You have an error in your SQL syntax; check your MySQL server version for the right syntax to use near,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33591245/