views:

20

answers:

2

Hi. I tried this:

$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?

+2  A: 

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"];
MartyIX
+2  A: 

You need to use mysqli_fetch_array or similar.

Erik B