gpt4 book ai didi

MySQL 更新查询语法错误

转载 作者:行者123 更新时间:2023-11-29 12:00:29 25 4
gpt4 key购买 nike

我的查询出现错误,但我不明白问题所在。我得到的错误是

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 'range = '55', atkspeed = '0.95', m_damage = '0', p_damage = '38', mprotection = ' at line 1

虽然我使用的代码是这个

 $id = mysql_real_escape_string($_POST["id"]);
$value0 = mysql_real_escape_string($_POST["value0"]);
$value1 = mysql_real_escape_string($_POST["value1"]);
$value2 = mysql_real_escape_string($_POST["value2"]);
$value3 = mysql_real_escape_string($_POST["value3"]);
$value4 = mysql_real_escape_string($_POST["value4"]);
$value5 = mysql_real_escape_string($_POST["value5"]);
$value6 = mysql_real_escape_string($_POST["value6"]);
$value7 = mysql_real_escape_string($_POST["value7"]);
$value8 = mysql_real_escape_string($_POST["value8"]);
$value9 = mysql_real_escape_string($_POST["value9"]);
$value10 = mysql_real_escape_string($_POST["value10"]);


$query="UPDATE char_stats SET vita = '$value0', mana = '$value1', speed = '$value2', range = '$value3', atkspeed = '$value4', m_damage = '$value5', p_damage = '$value6', mprotection = '$value7', pprotection = '$value8', hp5 = '$value9', mp5 = '$value10' WHERE id_char_stats='$id'";

我还使用其他非常相似的查询,所以我不明白问题可能是什么。我正在考虑 char_stats 上的下划线,所以我尝试使用

char\_stats

为了逃避,但无论如何它都不起作用。

提前致谢

最佳答案

create table t11
(
id int not null,
`range` int not null,
speed int not null
);

update t11 set range='11', speed=1; -- blows up
update t11 set `range`='11', speed=1; -- fine
update t11 set `range`=11, speed=1; -- fine

商店的道德:反勾号范围。如果没有它,即使创建表也会崩溃。

查看mysql关键字和保留字hereRange 就是其中之一。

所以你的查询将变成:

$query="UPDATE char_stats SET vita = '$value0', mana = '$value1', speed = '$value2', `range` = '$value3', atkspeed = '$value4', m_damage = '$value5', p_damage = '$value6', mprotection = '$value7', pprotection = '$value8', hp5 = '$value9', mp5 = '$value10' WHERE id_char_stats='$id'";

关于MySQL 更新查询语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32454497/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com