有人可以修改我的查询,我无法让它工作。
UPDATE `users` SET `steamName`, `steamRealName`, `ip` = VALUE('$steamName', '$steamRealName', '$ip') where `steamID` = '$steamID'
我正在尝试使用我的数据库表中的数据替换用户的Steam名称,实名和IP地址,但仅针对Steam ID = $ steamID的列。
我使用了以下变量:
$steamID = $_SESSION['steamid'];
$steamName = $steamprofile['personaname'];
$steamRealName = $steamprofile['realname'];
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
};
答案 0 :(得分:1)
将您的语句更改为有效的SQL语句:
UPDATE `users` SET `steamName` ='$steamName', `steamRealName` ='$steamRealName', `ip` = '$ip' where `steamID` = '$steamID'
答案 1 :(得分:0)
您的查询语法错误。应该是这样的:
UPDATE `users` SET `steamName`='$steamName', `steamRealName`='$steamRealName', `ip` = '$ip' where `steamID` = '$steamID'
语法为:
Update tablename
set col1=val1,
col2=val2,
col3=val3
where condition
答案 2 :(得分:0)
30 * * * * php ./maintenance/runJobs.php
语法应为:
UPDATE
即
UPDATE theTable SET col1 = col1Val, col2 = col2Val WHERE whereCol = whereColVal;
另请注意,UPDATE `users` SET `steamName` = '$steamName', `steamRealName` = '$steamRealName', `ip` = '$ip' where `steamID` = '$steamID';
可能会被欺骗。您不希望在查询中使用此非转义。
答案 3 :(得分:0)
试试这个:
Navigation.prototype.save = function(form) {
if(!this.check_completed()) {
this.handle_percentage();
this.strip_space(form);
form[0].getElementsByClassName("gform_save_link")[0].click();
}
}
答案 4 :(得分:0)
您遇到语法问题,请尝试以下方法:
UPDATE `users` SET `steamName` = '$steamName', `steamRealName` ='$steamRealName', `ip` = '$ip' where `steamID` = '$steamID'
答案 5 :(得分:0)
试试这个,
UPDATE `users`
SET `steamName` = '$steamName',
`steamRealName` = '$steamRealName',
`ip` = '$ip'
WHERE `steamID` = '$steamID'
尝试在PDO中使用Prepared语句。
答案 6 :(得分:0)
首先尝试这个:
UPDATE `users`
SET
`steamName` = '$steamName',
`steamRealName` = '$steamRealName',
`ip` = '$ip'
WHERE `steamID` = '$steamID'
但我强烈建议您使用预准备语句(请参阅PDO)以避免SQL注入漏洞。
此外,请勿直接访问$_SERVER
,而是清理它:
$ip = filter_input(INPUT_SERVER, 'HTTP_CLIENT_IP', FILTER_SANITIZE_STRING);
答案 7 :(得分:0)
请替换代码
UPDATE `users` SET `steamName`, `steamRealName`, `ip` = VALUE('$steamName', '$steamRealName', '$ip') where `steamID` = '$steamID'
进入
UPDATE users SET steamName='".$steamName."', steamRealName='".$steamRealName."', ip='".$ip."' where `steamID` = '$steamID';