本文翻译自:phpmyadmin - count(): Parameter must be an array or an object that implements Countable
I've uploaded the backup to a table, opening the table I see this: 我已将备份上传到一个表,打开该表,我看到了:
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)
Inside phpMyAdmin... 在phpMyAdmin内部...
PHP is 7.2, the server is Ubuntu 16.04, installed yesterday. PHP是7.2,服务器是Ubuntu 16.04,已于昨天安装。
Looking for I saw that some have this error in their code, but I did not find anyone who received it in phpMyAdmin... 寻找我发现有些人在他们的代码中有此错误,但是我没有在phpMyAdmin中找到任何收到此错误的人...
What should I do? 我该怎么办? Is that my error? 那是我的错误吗? A phpmyadmin error? phpmyadmin错误? wait update ? 等待更新? I go back to PHP 7.1? 我回到PHP 7.1吗?
参考:https://stackoom.com/question/3FPOr/phpmyadmin-count-参数必须是实现Countable的数组或对象
phpmyadmin 4.7.4 is supposed to have "Fixed several compatibility issues with PHP 7.2" phpmyadmin 4.7.4应该已经“解决了PHP 7.2的一些兼容性问题”
Chances are you have an older version of phpmyadmin. 您可能拥有较旧的phpmyadmin版本。
https://www.phpmyadmin.net/news/2017/8/24/phpmyadmin-474-released/ https://www.phpmyadmin.net/news/2017/8/24/phpmyadmin-474-released/
tested on Debian, should works on Ubuntu: 在Debian上测试过,应该可以在Ubuntu上运行:
1.) First download latest phpMyadmin file. 1.)首先下载最新的phpMyadmin文件。
2.) Delete (make a backup) all previous version file located in /usr/share/phpmyadmin
directory. 2.)删除(备份) /usr/share/phpmyadmin
目录中的所有先前版本文件。
3.) Uncompress to /usr/share/phpmyadmin/
directory all files of latest phpmyadmin. 3.)将最新phpmyadmin的所有文件解压缩到/usr/share/phpmyadmin/
目录。
4.) Modify file libraries/vendor_config.php
and change line: 4.)修改文件libraries/vendor_config.php
并更改行:
define('CONFIG_DIR', '');
to 至
define('CONFIG_DIR', '/etc/phpmyadmin/');
and 和
define('TEMP_DIR', './tmp/');
to 至
define('TEMP_DIR', '/tmp/');
5.) restart apache server and done. 5.)重新启动apache服务器并完成。
I found this PHP 7.2 count() - SYNTAX error in sql.lib.php 我在sql.lib.php中发现了此PHP 7.2 count()-SYNTAX错误
That perfectly works on my config: 这完全可以在我的配置上工作:
Debian 9,
PHP 7.2.3-1+0~20180306120016.19+stretch~1.gbp81bf3b (cli) (built: Mar 6 2018 12:00:19) ( NTS )
Open /usr/share/phpmyadmin/libraries/sql.lib.php
打开 /usr/share/phpmyadmin/libraries/sql.lib.php
Change line : Move parenthesis before == 换行 :将圆括号移到==之前
|| || ( (count($analyzed_sql_results['select_expr'] ) == 1) && ($analyzed_sql_results['select_expr'][0] == '*'))) ( (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;
}
Edit file /usr/share/phpmyadmin/libraries/sql.lib.php
: 编辑文件/usr/share/phpmyadmin/libraries/sql.lib.php
:
sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php
On line 613 the count function always evaluates to true since there is no closing parenthesis after $analyzed_sql_results['select_expr']
. 在第613行,由于$analyzed_sql_results['select_expr']
之后没有右括号,因此count函数始终求值为true。 Making the below replacements resolves this, then you will need to delete the last closing parenthesis on line 614, as it's now an extra parenthesis. 进行以下替换可解决此问题,然后您将需要删除第614行上的最后一个右括号,因为它现在是多余的括号。
Replace: 更换:
((empty($analyzed_sql_results['select_expr']))
|| (count($analyzed_sql_results['select_expr'] == 1)
&& ($analyzed_sql_results['select_expr'][0] == '*')))
With: 带有:
((empty($analyzed_sql_results['select_expr']))
|| (count($analyzed_sql_results['select_expr']) == 1)
&& ($analyzed_sql_results['select_expr'][0] == '*'))
Restart the server apache: 重新启动服务器apache:
sudo service apache2 restart
Try replace this function in file: /usr/share/phpmyadmin/libraries/sql.lib.php 尝试在以下文件中替换此功能:/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;
}