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

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?


当前回答

由于conf文件中的代码错误可能会有所不同(@Jacky Nguyen vs @ĦΔŇĐŘΔ ŇΔҜҜΔ answers),一般解决方案的答案是 A)修正conf文件中的条件逻辑使之有意义 (x)或b)安装正确的/当前phpmyadmin

至于a)

open the file with error code For the terminal people: sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php For the regular folks: sudo gedit /usr/share/phpmyadmin/libraries/sql.lib.php find the condition - basically search for $analyzed_sql_results['select_expr'] now the logic should be to check whether this sub array is empty, or, whether it has just 1 element with a value "* so basically the block between && $analyzed_sql_results['select_from']and && count($analyzed_sql_results['select_tables']) == 1 should look something like this

& & ( Empty ($analyzed_sql_results['select_expr']) //子数组为空, | | / /, ( (count($analyzed_sql_results['select_expr']) == 1) //只有一个元素 && //和同时 ($analyzed_sql_results['select_expr'][0] == '*') // 1元素值为"*" ) )

这是一个很好的例子,为什么缩进和美化你的代码,如果它将缩进正确,我相信这永远不会发生,或者至少,会更容易找到。

其他回答

只需纠正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;
}

我发现这个PHP 7.2 count() -语法错误在sql.lib.php

这完美地工作在我的配置:

Debian 9, 
PHP 7.2.3-1+0~20180306120016.19+stretch~1.gbp81bf3b (cli) (built: Mar  6 2018 12:00:19) ( NTS )

打开/usr/share/phpmyadmin/libraries/sql.lib.php

更改行:移动==前面的括号

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

in

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;
 }

根据@jbator的回答,你可以编辑/usr/share/phpmyadmin/libraries/plugin_interface.lib.php并替换这一行:

if ($options != null && count($options) > 0) {

用这些句子:

if ($options != null &&
   ((is_array($options) || $options instanceof Countable) && count($options) > 0) ||
   (method_exists($options, 'getProperties') && $options->getProperties() != null && (is_array($options->getProperties()) || $options->getProperties() instanceof Countable) && count($options->getProperties()) > 0)) {

这样,导出的文件就不会是空的了。

这在Ubuntu 18.04上运行得很好。

打开sql.lib.php文件

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

替换这个错误代码:

|| (count($analyzed_sql_results['select_expr'] == 1)

比如这个:

|| ((count($analyzed_sql_results['select_expr']) == 1)

保存文件。

重新启动你的服务器:

sudo service apache2 restart

并刷新PhpMyAdmin

编辑/usr/share/phpmyadmin/libraries/sql.lib.php文件

在错误上看到一个错误

./libraries/sql.lib.php#2038: PMA_isRememberSortingOrder(array)
./libraries/sql.lib.php#1984: PMA_executeQueryAndGetQueryResponse(

转到这一行并删除函数调用。

这对我很管用。