我已经上传了备份到一个表,打开表我看到这个:

Warning in ./libraries/sql.lib.php#601
count(): Parameter must be an array or an object that implements Countable

Backtrace

./libraries/sql.lib.php#2038: PMA_isRememberSortingOrder(array)
./libraries/sql.lib.php#1984: PMA_executeQueryAndGetQueryResponse(
array,
boolean true,
string 'alternativegirls',
string 'tgp_photo',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `tgp_photo`',
NULL,
NULL,
)
./sql.php#216: PMA_executeQueryAndSendQueryResponse(
array,
boolean true,
string 'alternativegirls',
string 'tgp_photo',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `tgp_photo`',
NULL,
NULL,
)
./index.php#53: include(./sql.php)

在phpMyAdmin……

PHP是7.2,服务器是Ubuntu 16.04,昨天安装的。

我看到一些人在他们的代码中有这个错误,但我没有发现任何人在phpMyAdmin中收到它…

我该怎么办?这是我的错误吗?phpmyadmin错误?等待更新?回到PHP 7.1?


当前回答

如果有人在DB导出页面中有类似的错误(我在Ubuntu 18.04中有这个问题),然后用代码替换文件/usr/share/phpmyadmin/libraries/plugin_interface.lib.php中的551行

if ($options != null && (is_array($options) || $options instanceof Countable) && count($options) > 0) {

其他回答

我尝试了以上所有的解决方案,但都不适合我。

试试这个:

安装所需的PHP版本(在我的例子中是7.0),然后在终端中键入

sudo update-alternatives --config php

输出如下所示:-

然后,只需输入选择号(在我的例子中是1),就可以切换到任何版本的PHP。

希望这可以帮助其他-:)

使用以下命令编辑/usr/share/phpmyadmin/libraries/sql.lib.php文件:

sudo nano +613 /usr/share/phpmyadmin/libraries/sql.lib.php

在第613行,count函数的计算结果总是为true,因为$analyzed_sql_results['select_expr']后没有右括号。进行下面的替换可以解决这个问题,然后需要删除第614行上的最后一个右括号,因为它现在是一个额外的括号。

替换:

((empty($analyzed_sql_results['select_expr']))
    || (count($analyzed_sql_results['select_expr'] == 1)
        && ($analyzed_sql_results['select_expr'][0] == '*')))

:

((empty($analyzed_sql_results['select_expr']))
    || (count($analyzed_sql_results['select_expr']) == 1)
        && ($analyzed_sql_results['select_expr'][0] == '*'))

重启服务器apache:

sudo service apache2 restart

添加phpmyadmin ppa

sudo add-apt-repository ppa:phpmyadmin/ppa
sudo apt-get update
sudo apt-get upgrade

只需纠正count()函数和右括号 /usr/share/phpmyadmin/libraries/sql.lib.php文件中的604行到615行:

function PMA_isRememberSortingOrder($analyzed_sql_results)
{
    return $GLOBALS['cfg']['RememberSorting']
        && ! ($analyzed_sql_results['is_count']
            || $analyzed_sql_results['is_export']
            || $analyzed_sql_results['is_func']
            || $analyzed_sql_results['is_analyse'])
        && $analyzed_sql_results['select_from']
        && ((empty($analyzed_sql_results['select_expr']))
            || (count($analyzed_sql_results['select_expr']) == 1)
                && ($analyzed_sql_results['select_expr'][0] == '*'))
        && count($analyzed_sql_results['select_tables']) == 1;
}

替换功能:

function PMA_isRememberSortingOrder($analyzed_sql_results) {
return $GLOBALS['cfg']['RememberSorting']
    &&!(
        $analyzed_sql_results['is_count']
        || $analyzed_sql_results['is_export']
        || $analyzed_sql_results['is_func']
        || $analyzed_sql_results['is_analyse']
    )&&
    $analyzed_sql_results['select_from']&&
    (
        empty($analyzed_sql_results['select_expr'])||
        count($analyzed_sql_results['select_expr'])==1&&
        $analyzed_sql_results['select_expr'][0] == '*'
    )
    && count($analyzed_sql_results['select_tables']) == 1;
}