我正在尝试获取表中的所有行。当我在我的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'];
}
这些代码在我的实时服务器中不起作用。
根据http://php.net/manual/en/mysqli-result.fetch-all.php该函数自PHP 5.3起就可用也许PHP服务器版本比较旧。