PHP mysqli_fetch_all给我一个空白屏幕 [英] PHP mysqli_fetch_all gives me a blank screen

查看:96
本文介绍了PHP mysqli_fetch_all给我一个空白屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是将某些东西从本地计算机推送到了实时站点,到处都是空白页.当我使用所有故障时,我将问题归结为mysqli_fetch_all.为什么这样做呢?以及如何解决?如果我使用mysqli_fetch_array或mysqli_fetch_row或mysqli_fetch_assoc,它可以工作,但我的数据无法正确显示.

I just pushed something from my local machine to the live site and I get blank pages everywhere. I tracked down the problem to mysqli_fetch_all when I use that everything breaks. Why is it doing this? and how do I fix it? if I use mysqli_fetch_array or mysqli_fetch_row or mysqli_fetch_assoc it works but my data is not displayed properly.

这是一个正在中断的功能:

This is one the functions that is breaking:

function getUserFields($connection){

        $query = mysqli_query($connection, "DESCRIBE `adminUsers`");
        $results = mysqli_fetch_all($query, MYSQLI_ASSOC);
        return $results;

}

$connection是到我的数据库的连接,我已经确认可以正常工作并且填充了$ query sting,只是mysqli_fetch_all不起作用,如何在不调整数据方式的情况下在函数中修复此问题?当前显示.

The $connection is the connection to my database, I have confirmed that works and $query sting is getting populated, it just the mysqli_fetch_all does not work, how could I fix this in the function without adjusting how the data is displayed currently.

推荐答案

函数mysqli_fetch_all()及其面向对象的对象(mysqli_result::fetch_all)仅在PHP 5.3和更高版本中可用.

The function mysqli_fetch_all() and its object oriented counterpart (mysqli_result::fetch_all) are only available in PHP 5.3 and later.

您的服务器似乎正在运行较低版本的PHP,或者您缺少 MySQL本机驱动程序(此功能所依赖),它解释了为什么其他提取功能可以工作,而不能正常工作.

It appears your server is running a lower version of PHP, or you're missing MySQL Native Driver (which this function depends on), which explains why the other fetch functions work and this doesn't.

手册:

mysqli_fetch_all
mysqli_result :: fetch_all
(PHP 5> = 5.3.0)

mysqli_fetch_all
mysqli_result::fetch_all
(PHP 5 >= 5.3.0)

为了将来进行调试,请打开错误或参考错误日志,因为这通常有助于识别问题.

For future debugging, turn errors on or refer to your error log because this will usually help to identify the problem.

error_reporting(E_ALL);
ini_set('display_errors', '1');

如果您无权升级PHP版本或安装MySQLND,则可以简单地将代码转换为使用mysqli_fetch_assoc()手动进行迭代:

If you don't have access to upgrade the PHP version, or install MySQLND, you can simply convert the code to manually iterate using mysqli_fetch_assoc():

function getUserFields($connection){
    $query = mysqli_query($connection, "DESCRIBE `adminUsers`");    
    $results = array();

    if($query){
        while($row = mysqli_fetch_assoc($query)){
            $results[] = $row;
        }
    }

    return $results;
}

这篇关于PHP mysqli_fetch_all给我一个空白屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆