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

It’s possible that when you installed phpMyAdmin, the version in the repository (phpMyAdmin v4.6.6) was not fully compatible with PHP 7.2. There is a newer version available on the official website (v4.9 as of writing), which fixes these compatibility issues with PHP 7.2.

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.85 (158 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 68% using AI 🤖. Read my Ezoic review to find out how.

202 replies

avatar
  Subscribe  
newest oldest
Notify of
Laszlo Babaly
Guest
Laszlo Babaly
Laszlo Babaly
11 days ago

Thanks a lot for your help!

W. R. Knight
Guest
W. R. Knight
W. R. Knight
29 days 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
Guest
Kuldip gadhiya
Kuldip gadhiya
4 months ago

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

Irakli
Guest
Irakli
Irakli
4 months ago

Works like a charm. Thanks

Jose Campos
Guest
Jose Campos
Jose Campos
4 months ago

Excellent! You save my life twice.

Fernando
Guest
Fernando
Fernando
4 months ago

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

Andy McBean
Guest
Andy McBean
Andy McBean
4 months ago

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

Ulises
Guest
Ulises
Ulises
4 months ago

Thank you very much. It is very helpful.

Bendt
Guest
Bendt
Bendt
6 months ago

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

Keshu
Guest
Keshu
Keshu
6 months ago

Amazing runing smooth now.

Dan
Guest
Dan
Dan
6 months ago

Works. Thank you

Xavier Juan
Guest
Xavier Juan
Xavier Juan
6 months ago

Thank you! Works great.

Vincent Adipo
Guest
Vincent Adipo
Vincent Adipo
6 months ago

Thank you! Works great.

Antonio
Guest
Antonio
Antonio
6 months 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
Guest
Lener Matos
Lener Matos
7 months ago

thank you!!!

Maya
Guest
Maya
Maya
8 months ago

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

John
Guest
John
John
8 months ago

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

Saras Kohli
Guest
Saras Kohli
Saras Kohli
8 months ago

Resolved Thanks

Okay
Guest
Okay
Okay
8 months ago

Thank you! Works great!

spicer
Guest
spicer
spicer
8 months ago

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

spicer
Guest
spicer
spicer
8 months 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
Guest
Sjoerd
Sjoerd
9 months ago

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

Silverio Fernandez Del Rosario
Guest
Silverio Fernandez Del Rosario
Silverio Fernandez Del Rosario
10 months 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
Guest
DarXyde
DarXyde
10 months 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
Guest
kotresh
kotresh
10 months ago

Thanks for the article. All problems are resolved,

Aydın Tez
Guest
Aydın Tez
Aydın Tez
10 months ago

Adamsın

Herman the German
Guest
Herman the German
Herman the German
10 months ago

Dankeschön!

Wallace
Guest
Wallace
Wallace
11 months ago

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

barni363hun
Guest
barni363hun
barni363hun
11 months ago

me too! 🙂
thanks

KH
Guest
KH
KH
11 months ago

Thank you for posting the solution, it finally works!

Buddy
Guest
Buddy
Buddy
11 months 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
Guest
Neale
Neale
11 months ago

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

Davide
Guest
Davide
Davide
1 year ago

Thanks a lot!

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

gus
Guest
gus
gus
1 year ago

thanks a lot

Joe
Guest
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
Guest
Julian Wagner
Julian Wagner
1 year ago

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

Peter Mose-Christensen
Guest
Peter Mose-Christensen
Peter Mose-Christensen
1 year ago

Excellent !

Dan Cacovean
Guest
Dan Cacovean
Dan Cacovean
1 year ago

great tut!!!

Abu Garcia
Guest
Abu Garcia
Abu Garcia
1 year ago

Gracias!

gunange
Guest
gunange
gunange
1 year ago

Thank You 🙂

hanh
Guest
hanh
hanh
1 year ago

Thank a lot

ovo
Guest
ovo
ovo
1 year ago

Thanks alot!

Cameron
Guest
Cameron
Cameron
1 year ago

Thank you!

vikas
Guest
vikas
vikas
1 year ago

nice helping

Graham
Guest
Graham
Graham
1 year ago

THANK YOU!

Alex
Guest
Alex
Alex
1 year ago

Perfecto, Gracias!!… funcionó en LMint 19.2

Rajesh Chaudhary
Guest
Rajesh Chaudhary
Rajesh Chaudhary
1 year ago

Thank You Very much…

Yiannis
Guest
Yiannis
Yiannis
1 year ago

Thanks! Saved my day!!

Edwin Rivero
Guest
Edwin Rivero
Edwin Rivero
1 year ago

Muchas Gracias. Funciona!!!

zayo
Guest
zayo
zayo
1 year ago

GREAT, ITS WORK! thank you very much!!!

Jabroni
Guest
Jabroni
Jabroni
1 year ago

Thank God for people like you. Much appreciated.