Reputation: 766
My Php code on my ubuntu webmin mysql server:
$reqdiasserver = "SELECT * from user_data WHERE `googleID` like 1234;";
$userdias = mysqli_query($conn ,$reqdiasserver);
$somanydias = mysqli_fetch_array($userdias , MYSQL_ASSOC);
echo '<pre>'; print_r($reqdiasserver); print_r($userdias); print_r($somanydias);
echo "NAME: " . $somanydias["name"];
Gives this result:
SELECT * from user_data WHERE `googleID` like 1234;mysqli_result Object
(
[current_field] => 0
[field_count] => 38
[lengths] =>
[num_rows] => 1
[type] => 0
)
NAME: 0
But the name at googleID '1234' is 'emanuel' and not 0
the structure of googleID in the db is text because gID's are too long I think for integers
why does it result 0 ?
Upvotes: 1
Views: 63
Reputation: 8288
this line:
$somanydias = mysqli_fetch_array($userdias , MYSQL_ASSOC);
should be as:
$somanydias = mysqli_fetch_array($userdias , MYSQLI_ASSOC);
// notice this ^
Upvotes: 3