【发布时间】:2014-04-16 19:24:55
【问题描述】:
我知道有很多这样的问题,但它们似乎都不起作用,我在语法上找不到错误!
mysql_query("SELECT `type` FROM `poststuff` WHERE `post_id` = 7 AND `user_id` = 1");
任何帮助都会很棒! (顺便说一句,标题上有错误) 完整代码(给你们的人-,-)
function update_post($post_id, $user_id) {
$result = mysql_result(mysql_query("SELECT `type` FROM `poststuff` WHERE `post_id` = $post_id AND `user_id` = $user_id"), 0) or die(mysql_error());
if ($result !== null) {
if ($result === "no" ) {
$actual_count = mysql_result(mysql_query("SELECT `$result` FROM `posts` WHERE `post_id` = $post_id"), 0);
mysql_query("UPDATE `posts` SET `$actual_count` = $actual_count+1 WHERE `post_id` = $post_id AND `type` = 'no'");
}
【问题讨论】:
-
给出你的表结构
-
7 和 1 实际上在查询中还是变量?
-
是的,它们不需要单引号,因为它们是整数,对吧?
-
是的,整数不需要单引号。
-
我在 phpMyAdmin 中遇到了这个错误,只有这个查询!