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

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?


当前回答

phpmyadmin 4.7.4应该有“修复了与PHP 7.2的几个兼容性问题”

您可能有一个较旧版本的phpmyadmin。

https://www.phpmyadmin.net/news/2017/8/24/phpmyadmin-474-released/

其他回答

对于我的phpmyadmin版本(4.6.6deb5),我找到了第613行,并意识到count()括号没有正确关闭。要在下次发布之前暂时修复这个问题,只需更改:

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

to:

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

在ubuntu-18.04上执行以下步骤:

步骤1)定位sql.lib.php

它将显示如下内容:

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

步骤2)打开终端(Alt t)并写入:

sudo /usr/sbin/pma-configure

步骤3)执行gedit /usr/share/phpmyadmin/libraries/sql.lib.php 和搜索下面的函数:

 

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

步骤4)将上述功能替换为:


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

步骤4)在终端上保存并关闭文件和以下命令

sudo /usr/sbin/pma-secure

步骤5)sudo service mysql reload

步骤6)sudo service apache2重载

这对我有用。 古德勒克

这在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

在Ubuntu 18.04上,使用MariaDb和Nginx,我通过更新文件/usr/share/phpmyadmin/libraries/sql.lib.php解决了这个问题,如下:

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

@Nguyen提到的答案抛出了一个500错误,说:

FastCGI sent in stderr: "PHP message: PHP Parse error:  syntax error, unexpected ')', expecting ';' in /usr/share/phpmyadmin/libraries/sql.lib.php on line 614"

由于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元素值为"*" ) )

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