开发者

MySQL query returns non-object?

I'm writing code for a user to update his password on a user account system.

This is the portion of code I am refe开发者_如何学运维rring to:

$checker = mysqli_query($db, "SELECT userid FROM tbl_user WHERE userpassword = '".md5($current)."'");
//echo "SELECT userid FROM tbl_user WHERE userpassword = '".md5($current)."'";
if ($checker == $_SESSION['exp_user']['userid']) {$check = true;} else {$check = false;}

For some reason, $checker is returning an object array rather than an object itself.

Doing a print_r($checker) produces this:

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

Any ideas on what I should be doing?


It doesn't return an "object array", just an object. The class of the object is mysqli_result (as expected) and it got some public fields like num_rows as seen on the manual of the MySQLi_Result class. If you want to read data from the result set you still have to use fetch methods like mysqli_result::fetch_assoc(), even if you result set contains only one row and one column.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜