phpMyAdmin and PHP 7 issues

Problem with phpMyAdmin and PHP 7.2: “Warning in ./libraries/sql.lib.php#613 count(): Parameter must be an array or an object that implements Countable”

Last updated on

These errors occur if your version of phpMyAdmin is not compatible with your version of PHP. For example, when PHP 7.2 was released, there were compatibility issues with some phpMyAdmin versions in the repository (phpMyAdmin v4.6.x). You can either resolve these issues by manually upgrading phpMyAdmin or you can instead alter some lines of code in phpMyAdmin to temporarily resolve the issue.

sql.lib.php

This error is caused by a line of code in /usr/share/phpmyadmin/libraries/sql.lib.php.

If you don’t want to wait for the repositories to update with the latest version, it is strongly recommended that you manually upgrade to the latest version of phpMyAdmin yourself.

Alternatively, you can make a change to sql.lib.php to temporarily fix the error.

Firstly, backup sql.lib.php before editing.

sudo cp /usr/share/phpmyadmin/libraries/sql.lib.php /usr/share/phpmyadmin/libraries/sql.lib.php.bak

Edit sql.lib.php in nano.

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

Press CTRL + W and search for (count($analyzed_sql_results['select_expr'] == 1)

Replace it with ((count($analyzed_sql_results['select_expr']) == 1)

Save file and exit. (Press CTRL + X, press Y and then press ENTER)

Import/Export issues

If you are also getting an error Warning in ./libraries/plugin_interface.lib.php#551 under import and export tabs:

Backup plugin_interface.lib.php

sudo cp /usr/share/phpmyadmin/libraries/plugin_interface.lib.php /usr/share/phpmyadmin/libraries/plugin_interface.lib.php.bak

Edit plugin_interface.lib.php

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

Press CTRL + W and search for if (! is_null($options) && count($options) > 0) {

If not found, try search for if ($options != null && count($options) > 0)

Replace with if (! is_null($options) && count((array)$options) > 0) {

Save file and exit. (Press CTRL + X, press Y and then press ENTER)

Upgrading phpMyAdmin

You may be interested in an article I wrote on manually upgrading phpMyAdmin. Since the release of Ubuntu 18.04, the repositories have been slow to update with the latest version of phpMyAdmin causing many compatibility issues, so make sure you have the latest version:

1 Star2 Stars3 Stars4 Stars5 Stars 4.84 (164 votes)

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.

Subscribe
Notify of
guest
209 Comments
newest
oldest
Inline Feedbacks
View all comments
CTA
CTA
1 month ago

Perfect! Star rock!!!

MTZG
MTZG
1 month ago

you rock dude, big thanks

SCSI
SCSI
3 months ago

Thank you for being so clear with you answers, and for covering multiple cases. You are a lifesaver.

Mysql
Mysql
3 months ago

Thanks!!!!

Nipper Shouse
Nipper Shouse
4 months ago

Perfect. Thank you very much.

Erik
Erik
4 months ago

Thanx x 1000000000 times.
🙂

Peter
Peter
5 months ago

You’re my GOD ^^

It work’s.

Laszlo Babaly
Laszlo Babaly
5 months ago

Thanks a lot for your help!

W. R. Knight
W. R. Knight
6 months ago

By God, it really works with Ubuntu 18.04 server, nginx, php 7.2, phpmydmin 4.6.6deb5 and mariadb 10.1.47.

Congratulations!!!

Kuldip gadhiya
Kuldip gadhiya
9 months ago

It is perfectly working in Linux mint 19
Thank you so much

Irakli
Irakli
9 months ago

Works like a charm. Thanks

Jose Campos
Jose Campos
9 months ago

Excellent! You save my life twice.

Fernando
Fernando
10 months ago

Thanks so much, it worked! I thought that the replies were bots.

Andy McBean
Andy McBean
10 months ago

Perfect. Thanks so much. Was getting this all the time when importing csv file. All sorted now.

Ulises
Ulises
10 months ago

Thank you very much. It is very helpful.

Bendt
Bendt
11 months ago

Amazing!!! it work in my rasberry pi 3 b+. Thank you very much!

Keshu
Keshu
11 months ago

Amazing runing smooth now.

Dan
Dan
11 months ago

Works. Thank you

Xavier Juan
Xavier Juan
11 months ago

Thank you! Works great.

Vincent Adipo
Vincent Adipo
11 months ago

Thank you! Works great.

Antonio
Antonio
1 year ago

a “sed” solution

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

Lener Matos
Lener Matos
1 year ago

thank you!!!

Maya
Maya
1 year ago

Thank you very much! it work in my rasberry pi 3 b+

John
John
1 year ago

Thank you very much! Now everything works fine on my RPI3b+!

Saras Kohli
Saras Kohli
1 year ago

Resolved Thanks

Okay
Okay
1 year ago

Thank you! Works great!

spicer
spicer
1 year ago

I solve the problem ^^
The sql.lib.php is in
/var/www/new/phpmyadmin/libraries
and not in
/usr/share/phpmyadmin/libraries

spicer
spicer
1 year ago

Not work for me.
I have tested with all variations (edit sql.lib.php, change to phpMyAdmin 5.x, change to phpMyAdmin 4.9.4)
After changes, phpmyadmin shows the old version and all buttons on left side (under phpmyadmin logo) are disappeared and the EHCP force panel is no longer displayed correctly.
Do you have a tip for me?

Sjoerd
Sjoerd
1 year ago

Thank you very much! Now everything works fine on my RPI3b!

Silverio Fernandez Del Rosario
Silverio Fernandez Del Rosario
1 year ago

Hola a todos, ejecute el comando:
sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php

y el resultado fue: “El directorio /usr/share/phpmyadmin/libraries/sql.lib.php” no existe,

estoy en ubuntu 18.04 LTS,

alguna solución,

un millon en gracias.

DarXyde
DarXyde
1 year ago

Great stuff, thanks!

While it did not necessarily got in the way of using phpMyAdmin, it was rather annoying to see that error every single time.

kotresh
kotresh
1 year ago

Thanks for the article. All problems are resolved,

Aydın Tez
Aydın Tez
1 year ago

Adamsın

Herman the German
Herman the German
1 year ago

Dankeschön!

Wallace
Wallace
1 year ago

Replace it with ((count($analyzed_sql_results[‘select_expr’]) == 1) worked for me.

barni363hun
barni363hun
1 year ago
Reply to  Wallace

me too! 🙂
thanks

KH
KH
1 year ago

Thank you for posting the solution, it finally works!

Buddy
Buddy
1 year ago

I’m pretty sure there is a typo: an extra parenthesis at the end of the second line.

If not found, try search for if ($options != null && count($options) > 0)

Replace with if (! is_null($options) && count((array)$options) > 0) {

Neale
Neale
1 year ago

Heh, thanks this has been bugging me for a while, thanks for both fixes.

Davide
Davide
1 year ago

Thanks a lot!

(How is it possible that a bug like this is still not fixed after months? 🙂 )

gus
gus
1 year ago

thanks a lot

Joe
Joe
1 year ago

Whats amazing is its nearly 2020 and this issue is still in the official phpmyadmin in the Ubuntu repository. When might it get fixed?

Julian Wagner
Julian Wagner
1 year ago

The sqllib trick didn’t work, but upgrading phpmyadmin did.

Peter Mose-Christensen
Peter Mose-Christensen
1 year ago

Excellent !

Dan Cacovean
Dan Cacovean
1 year ago

great tut!!!

Abu Garcia
Abu Garcia
1 year ago

Gracias!

gunange
gunange
1 year ago

Thank You 🙂

hanh
hanh
1 year ago

Thank a lot

ovo
ovo
1 year ago

Thanks alot!

Cameron
Cameron
1 year ago

Thank you!

vikas
vikas
1 year ago

nice helping