1
$saa = "update  aspirantdt set vote = 'vote'+1 where 'post_id' = '$id' ";

当我检查数据库时,值没有增加。帮帮我。

4

4 回答 4

1

您的查询中有一个sintax错误update,您使用的是引号而不是反引号。对列名使用反引号,对值使用引号尝试更改如下

$saa = "update  `aspirantdt` set `vote` = (`vote`+1) where `post_id` = '".$id."' ";
于 2013-04-20T08:16:45.900 回答
1

只需删除引号或使用 Backtics 作为列名。

$saa = "UPDATE  aspirantdt SET vote = vote + 1 where post_id = '$id' ";

或者用反引号

$saa = "UPDATE  `aspirantdt` SET `vote` = `vote` + 1 where `post_id` = '$id' ";
于 2013-04-20T08:17:02.953 回答
1
$saa = "update aspirantdt set vote = 'vote'+1 where 'post_id' = '$id' ";

表示'vote'and'post_id'文字字符串,而不是表名(也就是说,它将$id与实际字符串post_id而不是列的值进行比较post_id)。

您想要的是反引号将它们引用为列/表名称;

$saa = "update `aspirantdt` set `vote` = `vote`+1 where `post_id` = '$id' ";
于 2013-04-20T08:17:32.927 回答
0

您不需要引号vote作为列名,而不是字符串。

您的 SQL 可能正试图放入vote1一个 int 列。

于 2013-04-20T08:40:14.260 回答