我正在创建一个在订单成功时具有验证功能的页面
我正在尝试使用变量
逐步增加列的值但我一直收到错误
Error updating record: 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 '+ '57' WHERE Username = 'kokoman'' at line 2
这就是我正在使用的增量
$sql = "UPDATE users
SET package = '$packagex', diamonds + $diamondx, rate = '$ratx', amount + $amountx
WHERE Username = '$usernamex'";
继续产生上述错误
我正在使用它,因为我知道我是否需要增加列的值
我只想使用“set column +1”
但现在我正在尝试使用变量,因为它必须是动态的,但我得到了错误
请帮助坦克
答案 0 :(得分:1)
SET
子句需要包含赋值。 diamonds + $diamondx
应为diamonds = diamonds + $diamondx
,其他列也应如此。
您还应该停止将变量替换为查询,并学习使用带参数的预准备语句。
答案 1 :(得分:0)
根据我的理解,您希望为以前保留的列amount
和diamonds
的值增加值,请尝试以下操作:
$amountx = 1;
$diamondx = 1;
$sql = "UPDATE users
SET package = '$packagex',
diamonds = diamonds + $diamondx,
rate = '$ratx',
amount = amount + $amountx
WHERE Username = '$usernamex'";