PHP:IF语句或mysql_query将无法正常工作

时间:2014-01-05 15:08:53

标签: php mysql if-statement

我强烈认为IF或mysql_query不起作用。 (我想这是IF)

if(isset($_POST['delete']) && $admin == "3"){
        $query = mysql_query("DELETE FROM dis_posts WHERE post_id = '".$posts['post_id']."'");
        $result = mysql_query($query);
        header("Location: ". $_SERVER['REQUEST_URI']);
    }

请帮忙吗? 提前谢谢。

2 个答案:

答案 0 :(得分:0)

如果你的数据库连接没问题,那么就是 尝试这样:

   if(isset($_POST['delete']) && isset($admin) && $admin == "3"){
            $query = mysql_query("DELETE FROM dis_posts WHERE post_id = '".$posts['post_id']."'");
         if(!$query){

           echo "could not updated!";
         }else {
            header("Location: ". $_SERVER['REQUEST_URI']);
         }
   }

答案 1 :(得分:0)

我可能错了,但似乎这就是你想要做的......

if(isset($_POST['delete']) && $admin == "3"){
    $query = "DELETE FROM dis_posts WHERE post_id = '".$posts['post_id']."'";
    $result = mysql_query($query);
    if($result){
        header("Location: ". $_SERVER['REQUEST_URI']);
    }
}