Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 869
alebal Avatar asked Dec 28 '17 04:12

alebal


5 Answers

Edit file /usr/share/phpmyadmin/libraries/sql.lib.php using this command:

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

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:

sudo service apache2 restart
like image 83
Jacky Nguyen Avatar answered Oct 17 '22 08:10

Jacky Nguyen


The Easiest Method:

Just run this below command line in terminal and come back to PhpMyAdmin.

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.

like image 24
Chandra Nakka Avatar answered Oct 17 '22 08:10

Chandra Nakka


I found this PHP 7.2 count() - SYNTAX error in sql.lib.php

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

Change line: Move parenthesis before ==

|| ((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;
 }
like image 113
loquace Avatar answered Oct 17 '22 07:10

loquace


tested on Debian, should works on Ubuntu:

1.) First download latest phpMyadmin file.

2.) Delete (make a backup) all previous version file located in /usr/share/phpmyadmin directory.

3.) Uncompress to /usr/share/phpmyadmin/ directory all files of latest phpmyadmin.

4.) Modify file libraries/vendor_config.php and change line:

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.

like image 73
shibby Avatar answered Oct 17 '22 08:10

shibby


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

like image 42
Srikanth Ponnuru Avatar answered Oct 17 '22 09:10

Srikanth Ponnuru