[英]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?
Edit file /usr/share/phpmyadmin/libraries/sql.lib.php
using this command:使用以下命令编辑文件
/usr/share/phpmyadmin/libraries/sql.lib.php
:
sudo nano +613 /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 函数的计算结果总是为真。 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
Just run this below command line in terminal and come back to PhpMyAdmin.只需在终端中运行下面的命令行,然后返回到 PhpMyAdmin。 Now it works fine :)
现在它工作正常:)
sudo sed -i "s/|\s*\((count(\$analyzed_sql_results\['select_expr'\]\)/| (\1)/g" /usr/share/phpmyadmin/libraries/sql.lib.php
Open sql.lib.php file打开sql.lib.php文件
nano /usr/share/phpmyadmin/libraries/sql.lib.php
Find for count($analyzed_sql_results['select_expr']
code on file. You can get this at line ~ 613 . You can see this below wrong code Find for
count($analyzed_sql_results['select_expr']
code on file. 你可以在第 ~ 613行得到这个。你可以在错误代码下面看到这个
|| (count($analyzed_sql_results['select_expr'] == 1)
Just replace that wrong code with this below one只需用下面的代码替换那个错误的代码
|| ((count($analyzed_sql_results['select_expr']) == 1)
Save the file and come to PhpMyAdmin .保存文件并进入PhpMyAdmin 。
Now it works fine :)
现在它工作正常:)
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;
}
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 服务器并完成。
Edit file : '/usr/share/phpmyadmin/libraries/sql.lib.php'
编辑文件:
'/usr/share/phpmyadmin/libraries/sql.lib.php'
Replace : (count($analyzed_sql_results['select_expr'] == 1)
替换:(
(count($analyzed_sql_results['select_expr'] == 1)
With : (count($analyzed_sql_results['select_expr']) == 1
与:
(count($analyzed_sql_results['select_expr']) == 1
this worked for me这对我有用
如果有人在 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) {
Works on UBUNTU 18.04
Edit file: '/usr/share/phpmyadmin/libraries/sql.lib.php'
Replace: (count($analyzed_sql_results['select_expr'] == 1)
With: ((count($analyzed_sql_results['select_expr']) == 1)
Restart the server
sudo service apache2 restart
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/
Proceed following steps at ubuntu-18.04:在 ubuntu-18.04 执行以下步骤:
Step 1) locate sql.lib.php
步骤 1)找到
sql.lib.php
It will show something like:它会显示如下内容:
/usr/share/phpmyadmin/libraries/sql.lib.php
Step 2) Open terminal (Alt t) and write:步骤 2)打开终端 (Alt t) 并写入:
sudo /usr/sbin/pma-configure
Step 3) sudo gedit /usr/share/phpmyadmin/libraries/sql.lib.php
and search below function:步骤 3)
sudo 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; }
Step 4) Replace above function with:步骤 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; }
Step 4) Save & close file and below command on terminal步骤 4)在终端上保存并关闭文件和以下命令
sudo /usr/sbin/pma-secure
Step 5) sudo service mysql reload
步骤 5)
sudo service mysql reload
Step 6) sudo service apache2 reload
步骤 6)
sudo service apache2 reload
It works for me.. Goodluck它对我有用..祝你好运
Ubuntu 18.04 LTS Ubuntu 18.04 LTS
These are the steps which worked for me.这些是对我有用的步骤。 Many, many thanks to William Desportes for providing the automatic updates on their Ubuntu PPA.
非常感谢 William Desportes 在他们的 Ubuntu PPA 上提供自动更新。
Step 1 ( from William Desportes post )第 1 步(来自 William Desportes 帖子)
$ sudo add-apt-repository ppa:phpmyadmin/ppa
$
sudo add-apt-repository ppa:phpmyadmin/ppa
Step 2第 2 步
$ sudo apt-get --with-new-pkgs upgrade
$
sudo apt-get --with-new-pkgs upgrade
Step 3第 3 步
$ sudo service mysql restart
$
sudo service mysql restart
If you have issues restarting mysql, you can also restart with the following sequence如果重启mysql有问题,也可以按以下顺序重启
$ sudo service mysql stop;
$
sudo service mysql stop;
$ sudo service mysql start;
$
sudo service mysql start;
open this file: '/usr/share/phpmyadmin/libraries/sql.lib.php'
打开这个文件:'/usr/share/phpmyadmin/libraries/sql.lib.php'
sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php
press ctrl+w to search (count($analyzed_sql_results['select_expr'] == 1)
按 ctrl+w 搜索 (count($analyzed_sql_results['select_expr'] == 1)
Find: count($analyzed_sql_results['select_expr'] == 1)
Replace With: (count($analyzed_sql_results['select_expr']) == 1)
Restart the server
重启服务器
sudo service apache2 restart
moreover, If you still facing same issue then do following.此外,如果您仍然面临同样的问题,请执行以下操作。
open this file /usr/share/phpmyadmin/libraries/plugin_interface.lib.php
打开这个文件 /usr/share/phpmyadmin/libraries/plugin_interface.lib.php
sudo nano /usr/share/phpmyadmin/libraries/plugin_interface.lib.php
Find : if ($options != null && count($options) > 0) {
查找: if ($options != null && count($options) > 0) {
Ctrl+w : if ($options != null && count($options) > 0) {
replace with following code替换为以下代码
if ($options != null && count((array)$options) > 0) {
now save and restart the server现在保存并重新启动服务器
sudo /etc/init.d/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;
}
I think the best option is to update Phpmyadmin to a version which has this already fixed.我认为最好的选择是将 Phpmyadmin 更新到已修复此问题的版本。
Until it is published as a deb, you could do it like in @crimson-501 answer which I will copy below:在它作为 deb 发布之前,您可以像在@crimson-501 答案中那样做,我将在下面复制:
apt-get install phpmyadmin
.apt-get install phpmyadmin
。cd /usr/share
.cd /usr/share
。rm -rf phpmyadmin
.rm -rf phpmyadmin
。apt-get install wget
): wget -P /usr/share/ "https://files.phpmyadmin.net/phpMyAdmin/4.9.4/phpMyAdmin-4.9.4-english.zip"
Let me explain the arguments of this command, -P defines the path and "the link.zip" is currently (7/17/18) the latest version of PMA.apt-get install wget
): wget -P /usr/share/ "https://files.phpmyadmin.net/phpMyAdmin/4.9.4/phpMyAdmin-4.9.4-english.zip"
让我解释一下这个命令的参数,-P 定义路径,“link.zip”是当前(7/17/18)PMA 的最新版本。 You can find those links HERE .apt-get install unzip
): unzip phpMyAdmin-4.9.4-english.zip
.apt-get install unzip
): unzip phpMyAdmin-4.9.4-english.zip
。 We just unzipped PMA, now we will move it to it's final home.cp
(copy) command to move our files!cp
(复制)命令来移动我们的文件! Note that we have to add the -r
argument since this is a folder.-r
参数,因为这是一个文件夹。 cp -r phpMyAdmin-4.9.4-english phpmyadmin
. cp -r phpMyAdmin-4.9.4-english phpmyadmin
。rm -rf phpMyAdmin-4.9.4-english
.rm -rf phpMyAdmin-4.9.4-english
。 You might now notice two errors after you log into PMA.登录 PMA 后,您现在可能会注意到两个错误。
the configuration file now needs a secret passphrase (blowfish_secret). phpmyadmin
The $cfg['TempDir'] (./tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.
However, these issues are relatively easy to fix.但是,这些问题相对容易解决。 For the first issue all you have to do is grab your editor of choice and edit
/usr/share/phpmyadmin/config.inc.php
but there's a problem, we removed it!对于第一个问题,您所要做的就是获取您选择的编辑器并编辑
/usr/share/phpmyadmin/config.inc.php
但是有一个问题,我们删除了它! That's ok, all you have to do is: cd /usr/share/phpmyadmin
& cp config.sample.inc.php config.inc.php
.没关系,你所要做的就是:
cd /usr/share/phpmyadmin
& cp config.sample.inc.php config.inc.php
。
nano config.inc.php
and copy the dynamically generated secret from near the bottom of this page: https://www.question-defense.com/tools/phpmyadmin-blowfish-secret-generator . nano config.inc.php
并从本页底部附近复制动态生成的秘密: https : //www.question-defense.com/tools/phpmyadmin-blowfish-secret-generator 。 Example phpMyAdmin Blowfish Secret Variable Entry: phpMyAdmin Blowfish 秘密变量条目示例:
/*
* This is needed for cookie based authentication to encrypt password in
* cookie
*/
$cfg['blowfish_secret'] = '{^QP+-(3mlHy+Gd~FE3mN{gIATs^1lX+T=KVYv{ubK*U0V';
/* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
Now save and close the file.现在保存并关闭文件。
mkdir tmp
& chown -R www-data:www-data /usr/share/phpmyadmin/tmp
.mkdir tmp
& chown -R www-data:www-data /usr/share/phpmyadmin/tmp
。 The last command allows the Apache web server to own the tmp directory and edit it's contents.Ubuntu 18.10 (December, 2018) Ubuntu 18.10(2018 年 12 月)
Line 613, 614, 615, replace with:第 613、614、615 行,替换为:
|| count($analyzed_sql_results['select_expr']) == 1
&& ($analyzed_sql_results['select_expr'][0] == '*'))
&& count($analyzed_sql_results['select_tables']) == 1;
Work for me.. Ubuntu 18.04为我工作.. Ubuntu 18.04
sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php
Find for count($analyzed_sql_results['select_expr']
code on file. You can get this at line ~613.查找文件中的
count($analyzed_sql_results['select_expr']
代码。你可以在 ~613 行得到这个。
|| (count($analyzed_sql_results['select_expr'] == 1)
Just replace with code :只需用代码替换:
|| ((count($analyzed_sql_results['select_expr']) == 1)
Save the file and reload PhpMyAdmin.保存文件并重新加载 PhpMyAdmin。
Done!!!完成!!!
For my version of phpmyadmin (4.6.6deb5), I found line 613, and realized the count() parentheses were not closed properly.对于我的 phpmyadmin (4.6.6deb5) 版本,我找到了第 613 行,并意识到 count() 括号没有正确关闭。 To fix this temporarily until the next release, just change:
要在下一个版本之前暂时修复此问题,只需更改:
|| (count($analyzed_sql_results['select_expr'] == 1)
to:到:
|| (count($analyzed_sql_results['select_expr']) == 1
This is fixed in later versions of PHPMyAdmin.这在 PHPMyAdmin 的更高版本中得到了修复。 The Ubuntu Software Repositories for Ubuntu 18.04.2 holds version 4.6.6.5, while they're currently at 4.9.0.1.
Ubuntu 18.04.2 的 Ubuntu 软件存储库包含版本 4.6.6.5,而它们目前的版本为 4.9.0.1。 Updating your PHPMyAdmin installation will fix this problem, but might prove to be riskier than just editing that one line of code.
更新您的 PHPMyAdmin 安装将解决此问题,但可能证明比仅编辑那一行代码风险更大。 Here's how I did it on my Ubuntu Server.
这是我在 Ubuntu Server 上的做法。 Steps are essentially the same (with a different path) for all operating systems.
所有操作系统的步骤基本相同(具有不同的路径)。
wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.zip
unzip phpMyAdmin-4.9.0.1-all-languages.zip
cp -r /usr/share/phpmyadmin ~/phpmyadmin-backup
cd phpMyAdmin-4.9.0.1-all-languages
rm -r /usr/share/phpmyadmin/doc/html
cp -R * /usr/share/phpmyadmin/
Verify that it works.验证它是否有效。 If it doesn't, welll... You have a backup, so restore it and manually edit the faulty line.
如果没有,那么...你有一个备份,所以恢复它并手动编辑故障行。 In my own personal experience, I discovered after doing this that version 4.6.6.5 was not only riddled with bugs, but also incredibly slow compared to the new 4.9.0.1.
以我个人的经验,我在这样做之后发现 4.6.6.5 版本不仅漏洞百出,而且与新的 4.9.0.1 相比,速度也慢得令人难以置信。 The speed increase was pure magic for something I though was of "WordPress" quality.
对于我认为具有“WordPress”质量的东西来说,速度增加是纯粹的魔法。
Works on UBUNTU 16.04.3 Just open适用于 UBUNTU 16.04.3 刚打开
usr/share/libraries/sql.lib.php usr/share/libraries/sql.lib.php
modify修改
|| (count($analyzed_sql_results['select_expr'] == 1)
To至
|| ((count($analyzed_sql_results['select_expr']) == 1)
This worked for me;这对我有用;
sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php
Line No : 614线路编号 : 614
Replace two codes :替换两个代码:
Replace:替换:
(count($analyzed_sql_results[‘select_expr’] == 1)
With:与:
(count($analyzed_sql_results[‘select_expr’]) == 1)
AND和
Replace:替换:
($analyzed_sql_results[‘select_expr’][0] == ‘*’)))
With:与:
($analyzed_sql_results[‘select_expr’][0] == ‘*’))
save, exit and run保存,退出并运行
sudo service apache2 restart
This worked well for me on Ubuntu 18.04 .这在Ubuntu 18.04上对我很有效。
Open sql.lib.php file打开sql.lib.php文件
nano +613 /usr/share/phpmyadmin/libraries/sql.lib.php
Replace this wrong code:替换这个错误的代码:
|| (count($analyzed_sql_results['select_expr'] == 1)
With this one:有了这个:
|| ((count($analyzed_sql_results['select_expr']) == 1)
Save the file.保存文件。
Restart your server with:使用以下命令重新启动服务器:
sudo service apache2 restart
And refresh PhpMyAdmin并刷新PhpMyAdmin
Upgrade to phpMyAdmin 4.8.3.升级到 phpMyAdmin 4.8.3。 this solves the PHP 7.2 compatibility issues
这解决了 PHP 7.2 兼容性问题
Edit file '/usr/share/phpmyadmin/libraries/sql.lib.php' Replace: (make backup)编辑文件 '/usr/share/phpmyadmin/libraries/sql.lib.php' 替换:(进行备份)
"|| (count($analyzed_sql_results['select_expr'] == 1)
&&($analyzed_sql_results['select_expr'][0] == '*')))
&& count($analyzed_sql_results['select_tables']) == 1;"
With:与:
"|| (count($analyzed_sql_results['select_expr']) == 1)
&& ($analyzed_sql_results['select_expr'][0] == '*')
&& (count($analyzed_sql_results['select_tables']) == 1));"
Hi the following solve my same problem absolutely (import/export and so on):嗨,以下绝对解决了我同样的问题(导入/导出等):
Fix Bug Phpmyadmin [plugin_interface.lib.php] + Php7.2 + Ubuntu 16.04 修复错误 Phpmyadmin [plugin_interface.lib.php] + Php7.2 + Ubuntu 16.04
so... under ubuntu 18.04, mysql, php7.2: Terminal:所以......在ubuntu 18.04,mysql,php7.2下:终端:
sudo gedit /usr/share/phpmyadmin/libraries/plugin_interface.lib.php
Find the following line(ctrl+f):找到以下行(ctrl+f):
if ($options != null && count($options) > 0) {
it was on line #551 for me对我来说是#551
and change for following:并更改以下内容:
if ($options != null && count((array)$options) > 0) {
ctrl+s for save the changes ctrl+s 保存更改
and in terminal: ctrl+c for get back promt...并在终端中:ctrl+c 返回提示...
and: sudo systemctl restart apache2
和:
sudo systemctl restart apache2
"I think in new php version.It can't use count() or sizeof() with un array type. Force parameter to array is easy way to solve this bug,..." “我认为在新的 php 版本中。它不能使用具有 un 数组类型的 count() 或 sizeof()。强制参数到数组是解决此错误的简单方法,...”
Thanks for the original author for the problem solving!感谢原作者解决问题! I try to share it!
我试着分享!
|| ((count($analyzed_sql_results['select_expr']) == 1
This is what I changed in line 614 and phpmyadmin works without any error.这是我在第 614 行更改的内容,phpmyadmin 可以正常工作,没有任何错误。 Need one
(
before count, and one )
before ==
.在
==
之前需要一个(
在计数之前和一个)
。 That's it.就是这样。
Just correct the count()
function and closing parentheses from line 604 till 615 in /usr/share/phpmyadmin/libraries/sql.lib.php
file:只需更正
/usr/share/phpmyadmin/libraries/sql.lib.php
文件中第 604 行到 615 行的count()
函数和右括号:
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;
}
Open the /usr/share/phpmyadmin/sql.lib.php
file with elevated privileges, and edit the following in the function PMA_isRememberSortingOrder()
:使用提升的权限打开
/usr/share/phpmyadmin/sql.lib.php
文件,并在函数PMA_isRememberSortingOrder()
编辑以下内容:
|| count($analyzed_sql_results['select_expr'] == 1)
|| count($analyzed_sql_results['select_expr'] == 1)
|| count($analyzed_sql_results['select_expr'] == 1)
|| (count($analyzed_sql_results['select_expr']) == 1)
|| (count($analyzed_sql_results['select_expr']) == 1)
|| (count($analyzed_sql_results['select_expr']) == 1)
&& ($analyzed_sql_results['select_expr'][0] == '*')))
&& ($analyzed_sql_results['select_expr'][0] == '*')))
&& ($analyzed_sql_results['select_expr'][0] == '*'))
&& ($analyzed_sql_results['select_expr'][0] == '*'))
Restart your Apache server: sudo service apache2 restart
.重新启动 Apache 服务器:
sudo service apache2 restart
。
Tested on Linux Mint 19.1 based on Ubuntu 18.04, with PhpMyAdmin 4.6.6 and PHP 7.2.在基于 Ubuntu 18.04、PhpMyAdmin 4.6.6 和 PHP 7.2 的 Linux Mint 19.1 上测试。
I tried all of above solution but didn't work for me.我尝试了上述所有解决方案,但对我不起作用。
Try this:-试试这个:-
Install required version of PHP(in my case 7.0) and then in terminal, type安装所需版本的 PHP(在我的情况下为 7.0),然后在终端中,键入
sudo update-alternatives --config php
Output will be like this :-输出将是这样的:-
Then you can switch to any version of PHP by simply entering the selection number(in my case 1).然后您只需输入选择编号(在我的情况下为 1)即可切换到任何版本的 PHP。
Hope this may help other -:)希望这可以帮助其他人-:)
Replace Function:替换功能:
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;
}
Add the phpmyadmin ppa添加 phpmyadmin ppa
sudo add-apt-repository ppa:phpmyadmin/ppa
sudo apt-get update
sudo apt-get upgrade
add-apt-repository ppa:phpmyadmin/ppa
apt-get clean
apt-get update
apt-get purge phpmyadmin
apt-get install phpmyadmin
Fixed it for me, on Ubuntu 18.04.在 Ubuntu 18.04 上为我修复了它。
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?
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?
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?
On Ubuntu 18.04 with MariaDb and Nginx, I solved it with updating file /usr/share/phpmyadmin/libraries/sql.lib.php as follows: 在具有MariaDb和Nginx的Ubuntu 18.04上,我通过更新文件/usr/share/phpmyadmin/libraries/sql.lib.php解决了它,如下所示:
|| (count($analyzed_sql_results['select_expr']) == 1
The answer mentioned by @Nguyen throws a 500 error saying: @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"
is_countable function introduced in (PHP 7 >= 7.3.0) (PHP 7> = 7.3.0)中引入的is_countable函数
is_countable — Verify that the contents of a variable is a countable value. is_countable —验证变量的内容是否为可计数的值。
use this function following way :: 按照以下方式使用此功能::
is_countable ( $var )
It will return boolean value. 它将返回布尔值。 For more detail please visit on http://php.net/manual/en/function.is-countable.php
有关更多详细信息,请访问http://php.net/manual/en/function.is-countable.php
Based on @jbator's answer , you can edit /usr/share/phpmyadmin/libraries/plugin_interface.lib.php
and replace this line:根据@jbator 的回答,您可以编辑
/usr/share/phpmyadmin/libraries/plugin_interface.lib.php
并替换此行:
if ($options != null && count($options) > 0) {
with these lines:用这些行:
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)) {
In this way, we won't have empty exported file.这样,我们将不会有空的导出文件。
Take a look: https://devanswers.co/problem-php-7-2-phpmyadmin-warning-in-librariessql-count/ 看看: https : //devanswers.co/problem-php-7-2-phpmyadmin-warning-in-librariessql-count/
Firstly, backup sql.lib.php before editing. 首先,在编辑之前备份sql.lib.php。 Edit sql.lib.php in nano.
在nano中编辑sql.lib.php。
$ sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php $ sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php
Press CTRL + W and search for (count($analyzed_sql_results['select_expr'] == 1) 按CTRL + W并搜索(count($ analyzed_sql_results ['select_expr'] == 1)
Replace it with ((count($analyzed_sql_results['select_expr']) == 1) 将其替换为((count($ analyzed_sql_results ['select_expr'])== 1)
Save file and exit. 保存文件并退出。 (Press CTRL + X, press Y and then press ENTER)
(按Ctrl + X,按Y,然后按Enter)
none of these solutions worked for me you need to update phpmyadmin to the latest, follow instructions here 这些解决方案都不适合我,您需要将phpmyadmin更新为最新版本,请按照此处的说明进行操作
https://askubuntu.com/questions/947805/how-to-upgrade-phpmyadmin-revisited https://askubuntu.com/questions/947805/how-to-upgrade-phpmyadmin-revisited
Here's an automated patching script I threw together utilizing Chandra Nakka
's answer.这是我利用
Chandra Nakka
的答案拼凑的自动修补脚本。
FILE="/usr/share/phpmyadmin/libraries/sql.lib.php"
PATTERN="(count(\$analyzed_sql_results\['select_expr'\] == 1)"
echo "Verifying broken code in $FILE"
if grep -q "$PATTERN" "$FILE"; then
LINE_NUMBER=$(grep -n "$PATTERN" "$FILE" | cut -d : -f 1)
echo "Broken code found on line: $LINE_NUMBER"
BEFORE_CODE=$(sed -n "$LINE_NUMBER"p "$FILE")
echo -e "\nCreating backup of $FILE"
sudo cp "$FILE" "$FILE-backup-$(date +"%Y-%m-%dT%H%M%S")"
echo "Backup created at: $FILE-backup-$(date +"%Y-%m-%dT%H%M%S")"
echo -e "\nApplying fix"
sudo sed -i "s/|\s*\((count(\$analyzed_sql_results\['select_expr'\]\)/| (\1)/g" $FILE
AFTER_CODE=$(sed -n "$LINE_NUMBER"p "$FILE")
# Trim before and after code with xargs
echo "BEFORE: $(echo $BEFORE_CODE | xargs)"
echo " AFTER: $(echo $AFTER_CODE | xargs)"
else
echo "Broken code not found. Maybe it's already been patched 🤷"
fi
As the error in code in conf file may vary (@Jacky Nguyen vs @ĦΔŇĐŘΔ ŇΔҜҜΔ answers), 由于conf文件中代码中的错误可能会有所不同(@Jacky Nguyen与@ĦΔŇĐŘΔΔŇΔҜҜΔΔ答案),
the general solution answer would be to 通用解决方案的答案是
a) correct the condition logic in conf file to make sense a)更正conf文件中的条件逻辑以使其有意义
(x)or b) install corrected/current phpmyadmin (x)或b)安装正确/当前的phpmyadmin
As for a) 至于)
open the file with error code 用错误代码打开文件
For the terminal people: sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php
对于终端用户:
sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php
For the regular folks: sudo gedit /usr/share/phpmyadmin/libraries/sql.lib.php
对于普通人:
sudo gedit /usr/share/phpmyadmin/libraries/sql.lib.php
find the condition - basically search for $analyzed_sql_results['select_expr']
找到条件-基本上搜索
$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 " *
现在的逻辑应该是检查此子数组是否为空,或者是否只有1个值为“
*
”的元素
so basically the block 所以基本上是块
between && $analyzed_sql_results['select_from']
在
&& $analyzed_sql_results['select_from']
and && count($analyzed_sql_results['select_tables']) == 1
和
&& count($analyzed_sql_results['select_tables']) == 1
should look something like this 应该看起来像这样
&& ( empty($analyzed_sql_results['select_expr']) //the sub array is empty, || //or, ( (count($analyzed_sql_results['select_expr']) == 1) //it has just 1 element && //and at the same time ($analyzed_sql_results['select_expr'][0] == '*') //the 1 element value is "*" ) )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.