删除查询不删除

时间:2014-06-08 22:07:26

标签: php mysql sql sql-delete

我想知道为什么第一个删除查询无法正常工作,而第二个删除查询是否有效?

if(isset($_POST['accept request' . $user_from])) {
    $delete_request = mysql_query("DELETE FROM friend_requests WHERE user_from='$user_from' AND user_to='user_to'");
    header("location: friend_requests.php");

    echo "<br /><br />You are now friends with " . $user_to;

}

if(isset($_POST['ignorerequest' . $user_from])) {
    $delete_request = mysql_query("DELETE FROM friend_requests WHERE user_from='$user_from' AND user_to='$user_to'");
    header("location: friend_requests.php");
    echo "Friend Request Declined";
}

请忽略他们未准备好的事实,并且这是一个安全问题。我纯粹想知道为什么第一个删除请求不起作用(是的,if被正确触发)

1 个答案:

答案 0 :(得分:1)

您错过了user_to变量上的美元符号

"DELETE FROM friend_requests WHERE user_from='$user_from' AND user_to='$user_to'"