Reputation: 7576
$result = $conn->query("SELECT * FROM temp_users WHERE reg_code ='$passkey'");
This works:
if($result->num_rows == 1){
values from print_r($result);
mysqli_result Object ( [current_field] => 0 [field_count] => 11 [lengths] => [num_rows] => 1 [type] => 0 )
but $result->username
where username is a field in the db shows up blank?
Upvotes: 1
Views: 3000
Reputation: 28648
Yes, because you need to fetch a row from the $result
. It can be done via function: http://www.php.net/manual/en/mysqli-result.fetch-array.php and a few more - check PHP manual.
From manual:
/* associative array */
$row = $result->fetch_array(MYSQLI_ASSOC);
echo $row["username"];
Upvotes: 2