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

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

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

其他回答

在Debian上测试,应该在Ubuntu上工作:

1)。首先下载最新的phpMyadmin文件。

2)。删除(备份)位于/usr/share/phpmyadmin目录下的所有旧版本文件。

3)。解压所有phpmyadmin最新版本的文件到/usr/share/phpmyadmin/目录下。

4)。修改文件库/vendor_config.php并更改行:

define('CONFIG_DIR', '');

to

define('CONFIG_DIR', '/etc/phpmyadmin/');

and

define('TEMP_DIR', './tmp/');

to

define('TEMP_DIR', '/tmp/');

5.)重启apache服务器,完成。

如果有人在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) {

is_可数函数(PHP 7 >= 7.3.0)

is_countable -验证变量的内容是可数值。

使用此函数的方法如下:

Is_countable ($var)

它将返回布尔值。欲了解更多详情,请访问http://php.net/manual/en/function.is-countable.php

嗨,下面绝对解决了我同样的问题(导入/导出等):

修复Phpmyadmin [plugin_interface.lib.php] + Php7.2 + Ubuntu 16.04的错误

所以…在ubuntu 18.04下,mysql, php7.2: 终端:

sudo gedit /usr/share/phpmyadmin/libraries/plugin_interface.lib.php

找到下面的行(ctrl+f):

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

我是在551行

并更改如下:

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

Ctrl +s保存更改

在终端:ctrl+c for get back prompt…

然后:sudo systemctl restart apache2

“我认为在新的php版本。它不能对unarray类型使用count()或sizeof()。强制参数数组是解决这个错误的简单方法,…”

感谢原作者解决问题!我试着分享它!

使用以下命令编辑/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