phpmyadmin - count(): Parameter must be an array o

2019-01-16 00:51发布

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...

PHP is 7.2, the server is Ubuntu 16.04, installed yesterday.

Looking for I saw that some have this error in their code, but I did not find anyone who received it in phpMyAdmin...

What should I do? Is that my error? A phpmyadmin error? wait update ? I go back to PHP 7.1?

23条回答
看我几分像从前
2楼-- · 2019-01-16 01:10

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

this worked for me

查看更多
地球回转人心会变
3楼-- · 2019-01-16 01:11

Try replace this function in file: /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;
}
查看更多
forever°为你锁心
4楼-- · 2019-01-16 01:12

Easiest Method:

Just run this below command line in terminal and come back to 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

Manual Method:

Open sql.lib.php file

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

|| (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.

Now it works fine :)

查看更多
女痞
5楼-- · 2019-01-16 01:12

Warning in ./libraries/plugin_interface.lib.php#532

count(): Parameter must be an array or an object that implements Countable

count(): Parameter must be an array or an object that implements Countable

couse of phpmyadmin’s library try to count some parameter. At this line 532, I found this code in this path.

phpmyadmin’s library try to count some parameter

Edit File /usr/share/phpmyadmin/libraries/plugin_interface.lib.php at line 532:

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

Find the line if ($options != null && count($options) > 0) { and replace count($options) with count((array)$options).

enter image description here

Restart Apache Service:

sudo service apache2 restart

In new php version it can’t use count() or sizeof() with un array type. So you have to forcefully change the parameter to array here.

查看更多
贪生不怕死
6楼-- · 2019-01-16 01:12

I had this issue when using windows and the responses above solved it for me, however when i switched to linux (ubuntu 18.04 LTS) I had the same issue and couldn't figure out how to solve it because I didn't see the file '/usr/share/phpmyadmin/libraries/sql.lib.php'.

This sql.lib.php file wasn't in the share folder or the phpmyadmin/libraries folder of my /opt/lampp directory - since I was using xampp on my ubuntu. Based on the update made to the xampp (because I used the latest installation as of now) setup.

The answer is still to replace: (count($analyzed_sql_results['select_expr'] == 1)

With: (count($analyzed_sql_results['select_expr']) == 1

However the file to look for is Sql.php found in /opt/lampp/phpmyadmin/libraries/classes/Sql.php

Future updates or if you still don't find it: use grep -r 'count($analyzed_sql_results' /opt/lampp/phpmyadmin to search for matching documents in your directory and edit accordingly

查看更多
Root(大扎)
7楼-- · 2019-01-16 01:13

phpmyadmin 4.7.4 is supposed to have "Fixed several compatibility issues with PHP 7.2"

Chances are you have an older version of phpmyadmin.

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

查看更多
登录 后发表回答