gpt4 book ai didi

PHP MySQL "UPDATE"

转载 作者:行者123 更新时间:2023-11-30 23:01:57 25 4
gpt4 key购买 nike

我不知道为什么,但出于某种原因,下面的代码没有按预期工作

$SQL = "UPDATE characters SET
name = '$char_name',
status = '$char_status',
gender = $char_gender,
pos.x = $char_posx,
pos.y = $char_posz,
shards = $char_money,
level = $char_level,
exp = $char_exp,
hair = $char_hair,
color.r = $char_color_r,
color.g = $char_color_g,
color.b = $char_color_b,
spawn = $char_spawn
WHERE username = '$nick'";
mysql_query($SQL) or die("ERRORCODE 04 - DB QUERY FAIL");
echo "saved";

它总是给我“ERRORCODE 04..”意味着查询失败..

仅供引用:将 pos.y db 值设置为 char_posz 是正确的,因为坐标轴与实际数据库的表单不同

编辑:由于一些评论,代码现在有点改变,现在看起来像这样:

$SQL = "UPDATE characters SET
name = '$char_name',
status = '$char_status',
gender = $char_gender,
pos_x = $char_posx,
pos_y = $char_posz,
shards = $char_money,
level = $char_level,
exp = $char_exp,
hair = $char_hair,
color_r = $char_color_r,
color_g = $char_color_g,
color_b = $char_color_b,
spawn = $char_spawn
WHERE username = '$nick'";
mysqli_query($dbcon, $SQL) or die(mysqli_error($dbcon));
echo "saved";

这是我得到的错误:

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 ' pos_x = , pos_y = , shards = , ' at line 4

最佳答案

尝试在查询中的所有变量周围加上单引号

关于PHP MySQL "UPDATE",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23605357/

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