duanmiyang6201 2017-07-11 16:05
浏览 70
已采纳

mysql请求用PHP 7.1返回null,而5.3用ok

I'm facing a weird trouble.

I just installed a new virtual server with apache / php 7.1 in order to prepare the migration of my old virtual webserver running php 5.3.3. The reason is I need to install prestashop that requires php 5.4 (minimum requirement).

Both virtual servers are running centos 6 on the same HN.

PHP 7.1 comes from remi repos.

I ran this code on both VMs (CLI):

<?php
$mysql = new mysqli($mysql_adress, $mysql_login, $mysql_pwd, $mysql_database);
if($mysql->connect_error){
    echo 'connect error : '.$mysql->connect_error;
} else {
    $return = $mysql->query("SELECT DATABASE()");
    $row = mysqli_fetch_array($return, MYSQL_ASSOC);
    var_dump($row);
}
?>

My 'old' server returns the name of the database i am connected to (it is the expected result) but the new server returns NULL !

I suspect the mysqlnd client to be responsible for this behaviour but not sure.

Any idea appreciated !

  • 写回答

1条回答 默认 最新

  • dongtuji0992 2017-07-11 17:18
    关注

    Problem solved ! Thank to @yanman1234.

    MYSQL_ASSOC used to work with a mysqli object in the previous versions of php . This time is over and i should now use MYSQLI_ASSOC instead.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用