我在ubuntu webmin mysql服务器上的Php代码:

$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"];

给出以下结果:
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

但是googleID'1234'的名字是'emanuel',而不是0
数据库中googleID的结构是文本,因为gID对于整数来说太长了
为什么结果是0?

最佳答案

这一行:

$somanydias = mysqli_fetch_array($userdias , MYSQL_ASSOC);

应为:
$somanydias = mysqli_fetch_array($userdias , MYSQLI_ASSOC);
//                                    notice this ^

10-08 00:14