开发者

MySQLi Result not returning Anything

So I'm working on a project and everything's going fine until I try to pull information from a table in one specific method. Every other time I want data it's fine. But not now and I'm pretty much at my wits end. Basically this is what I have:

public function get_user_data ()
{
    $sql = $this->get_connection(); // returns a new mysqli object

    $tmp = unseria开发者_Go百科lize($_COOKIE[PREFIX.CLIENT_COOKIE]);

    $email = $sql->real_escape_string($tmp[0]);

    $stmt = $sql->query("SELECT * FROM `".USER_TABLE."` WHERE `email` = '{$email}';");

    return $stmt;
}

Which returns:

mysqli_result Object ( [current_field] => 0 [field_count] => 4 [lengths] => [num_rows] => 0 [type] => 0 )

Any idea of what this could be?


You need to do a step further at the end

// MySQLi->query returns FALSE on failure.    
$stmt = $sql->query("SELECT * FROM `".USER_TABLE."` WHERE `email` = '{$email}';");

if ($stmt) {
    // Returns an array of associative or numeric arrays holding result rows.
    return $stmt->fetch_all();  
} else {
    // False, failure
    return null;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜