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 | 215 replies

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:

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

215 replies

Leave a reply

Your email address will not be published. Required fields are marked *

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

    Congratulations!!!

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

  3. a “sed” solution

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

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

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

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

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

  8. 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) {

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

  10. Woooooooooow 🙂 y’re just an angel ! It worked for me when i modified the files. Thanks a lot

  11. Thank you so much ! It was amazingly helpful !
    Tired of that annoying warning message 😀
    Cheers, man!

  12. You saved me from a world of pain and horror, thank you! Works on Ubuntu 18.04.1 / PHP 7.2.17 / Apache 2.4.29. I was having trouble with exporting and the second fix did it for me. I applied both just in case.

  13. For the import/export issue you can replace the code with:
    if (! is_null($options) && count((array)$options) > 0) {

  14. For import/export issue ,
    If you don’t find : (! is_null($options) && count($options) > 0)
    search : if ($options != null && count($options) > 0)

  15. Import/Export issues
    If you are also getting an error Warning in ./libraries/plugin_interface.lib.php#551 under import and export tabs:
    Search:
    if ($options != null && count($options) > 0) {

  16. Very nice. Did it via FileZilla. Only download file, edit and upload. Or even edit it via nano and save. Reload the page in phpmyadmin and the error isnt there anymore. Thank you very much 😀

  17. it help me a lot but after this solution i am facing count () function is not working with group by . hosting to Digital Ocean Droplet where
    OS is Ubuntu 18.04,
    Apache2,
    PHP 7.2,
    Tomcat 9,
    MySQL 5.7 ,
    PhpMyAdmin 4.8.
    but same program is working in another hosting (not VPS) which is running.
    will you give me guideline ?

  18. I seem to have errors in phpmyadmin. I get Warning in ./libraries/plugin_interface.lib.php#551 under import and export tabs. I have done above 🙁

    1. 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) {
      

      Replace with

      if ($options != null) {
      

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

      1. I ended up taking a complete back flip. I worked out what i did wrong. I set up the database users incorrectly and wouldn’t connect. I ended up using a raspberry pi instead of laptop. Easier to make backups or repair if it goes down. I have found your posts very handy. thanks

      2. if not found: if (! is_null($options) && count($options) > 0) {

        please search: if ($options != null && count($options) > 0) { and … It works.

        1. Hi, thanks for the article and this comment. When I tried this, the section of the screen is blank. There is nothing in the section that has the import options.

      3. Carefull for some of us does changing this setting isn’t working, You get Blank Page, follow the steps @Ardhia Mangku Ikhsan Provided.

      1. Error in processing request
        Error code: 500
        Error text: Internal Server Error

        1, I get this error when selecting a table and query in Phpmyadmin.
        2, Also My imported files are not in the db.
        3, Export page in the created DB is blank.

        Kindly help me to solve this issue.
        Thank you in advance. Have a great day

        Regards,
        Sampath

        1. sudo sed -i “s/|s*((count($analyzed_sql_results[‘select_expr’])/| (1)/g” /usr/share/phpmyadmin/libraries/sql.lib.php