你好我试图更新我的数据库用户离开,我想插入所有用户数据:野兔是我的脚本:
$stmt = $connect->prepare("UPDATE users SET (
userid,
username,
usertype,
email,
level,
exp,
money,
ninjarank,
avatar,
village,
clan,
guild,
healthpoint,
chakrapoint,
ninjutsu,
taijutsu,
genjutsu,
senjutsu,
talent,
chakra,
health,
chakracontrol
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) WHERE userid= ?");
$stmt->bind_param("isisiiisssssiiiiiiiiiii",
$userid,
$username,
$usertype,
$email,
$level,
$exp,
$money,
$ninjarank,
$avatar,
$village,
$clan,
$guild,
$healthpoint,
$chakrapoint,
$ninjutsu,
$taijutsu,
$genjutsu,
$senjutsu,
$talent,
$chakra,
$health,
$chakracontrol,
$userid
);
$stmt->execute();
$stmt->close();
$connect->close();
但是这个查询根本没有工作得到任何结果,我设置了一个值+1000只是为了确保查询成功运行但数据库中的值是相同的请帮助这个查询
答案 0 :(得分:1)
这是INSERT
而非UPDATE
语法,请使用以下格式:
UPDATE users u
SET u.username = ?,
u.OtherColumn = ?,
......
WHERE u.user_id = ?
或者,如果您确实要插入,请将UPDATE
替换为INSERT
并删除WHERE
子句。