Php无法获得MYSQL数据库的正确信息

时间:2017-03-11 11:28:09

标签: php mysql

我的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&#39; 1234&#39;是伊曼纽尔&#39;而不是0

db中googleID的结构是文本,因为gID&#39; s太长了我认为是整数

为什么会导致0?

1 个答案:

答案 0 :(得分:3)

这一行:

$somanydias = mysqli_fetch_array($userdias , MYSQL_ASSOC);

应该是:

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