$saa = "update aspirantdt set vote = 'vote'+1 where 'post_id' = '$id' ";
当我检查数据库时,值没有增加。 帮助我。
答案 0 :(得分:1)
yuo在update
查询中出现语法错误,您使用的是引号而不是反引号。对列名称和引号使用反引号尝试更改如下
$saa = "update `aspirantdt` set `vote` = (`vote`+1) where `post_id` = '".$id."' ";
答案 1 :(得分:1)
只需删除引号或使用反引号作为列名。
$saa = "UPDATE aspirantdt SET vote = vote + 1 where post_id = '$id' ";
或者使用反引号
$saa = "UPDATE `aspirantdt` SET `vote` = `vote` + 1 where `post_id` = '$id' ";
答案 2 :(得分:1)
$saa = "update aspirantdt set vote = 'vote'+1 where 'post_id' = '$id' ";
表示'vote'
和'post_id'
是文字字符串,而非表名(即,它会将$id
与实际字符串{{1}进行比较而不是post_id
列的值)。
你想要的是反引号来引用它们作为列/表名称;
post_id
答案 3 :(得分:0)
vote
周围不需要引号作为列名,而不是字符串。
您的SQL可能正在尝试将vote1
放入int列。