execute()没有结果

时间:2014-06-12 08:12:40

标签: php mysql

我这里有两个查询,$ check_perms和$ get_projects。前者似乎有效,但不是后者。没有错误,只是没有结果,但我知道应该有。

$sessionUser = $_SESSION['user_id'];

$check_perms = $db->prepare("SELECT * FROM tasks WHERE id = ?");
$check_perms->bind_param('i', $par);
    if ($result = $check_perms->execute())
        if ($row = mysqli_fetch_assoc($result))
            if ($row['user'] != $sessionUser){
                echo "<container>Error. This is not your task.</container>";
                exit;
            }


$get_projects = Database::connect()->prepare("SELECT * FROM tasks WHERE user = ? ORDER BY weight DESC");
$get_projects->bind_param('i', $sessionUser);
    if ($result = $get_projects->execute())
        while ($row = mysqli_fetch_assoc($result))
            //stuff

1 个答案:

答案 0 :(得分:0)

您确定tasks.user字段是整数吗?尝试改变:

$check_perms->bind_param('i', $sessionUser);

$check_perms->bind_param('s', $sessionUser);