简体   繁体   中英

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 = unserialize($_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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM