DEV Community

loading...

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

Sushma Gangolu
Dev in love with React.js, HTML, and CSS. Friends with PHP, GCP, DigitalOcean. More excited about products than technology. In a startup.
・1 min read

Edit file /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']. 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

Discussion (2)

Collapse
abdes profile image
Zakari Abdessamad

Or run this command:

sudo sed -i "s/|\s*\((count(\$analyzed_sql_results\['select_expr'\]\)/| (\1)/g" /usr/share/phpmyadmin/libraries/sql.lib.php

Enter fullscreen mode Exit fullscreen mode
Collapse
zaekof profile image
NOGIER Loïc

Thanks :)