【问题标题】:Why mysqli_fetch_all() is undefined in my live server? [duplicate]为什么 mysqli_fetch_all() 在我的实时服务器中未定义? [复制]
【发布时间】:2016-04-02 05:38:27
【问题描述】:

我正在尝试获取表中的所有行。当我在我的 wamp 服务器中使用 mysqli_fetch_all() 函数时,它工作正常。但是在实时服务器中使用时,这个函数被称为未定义函数。

我可以使用mysqli_fetch_assoc() 函数获取单行数据。

$connection = mysqli_connect( 'localhost', 'root', '', 'students');

if( !$connection ) {
    echo 'Database establshin error ' . mysqli_connect_error().' And the error number is ' . mysqli_connect_errno();
}

$query = mysqli_query( $connection, "SELECT * FROM studentinfomation");
$results = mysqli_fetch_assoc( $query );

echo $results['studentName']; // THis is working fine..

但是当我使用mysqli_fetch_all() 函数时它不起作用:

$query= mysqli_query($connection, "SELECT * FROM studentinfomation");
$results = mysqli_fetch_all( $query, MYSQLI_ASSOC ); // This works in wamp server

foreach( $results  as $result ) {
  echo $result['studentName'];
}

此代码在我的实时服务器中不起作用。

【问题讨论】:

标签: php mysqli server


【解决方案1】:

根据http://php.net/manual/en/mysqli-result.fetch-all.php 此功能自 PHP 5.3 起可用 可能 PHP 服务器版本较旧。

【讨论】:

    猜你喜欢
    • 2015-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-13
    • 2018-04-07
    相关资源
    最近更新 更多