0

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

This is the portion of code I am referring 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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.