Home  >  Article  >  Backend Development  >  When count(): Parameter must be an array or an object that implements Countable Error Occurs in phpMyAdmin, What to Do?

When count(): Parameter must be an array or an object that implements Countable Error Occurs in phpMyAdmin, What to Do?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-10-20 12:56:30558browse

When count(): Parameter must be an array or an object that implements Countable Error Occurs in phpMyAdmin, What to Do?

Parameter Must be an Array or an Object that Implements Countable

Question:

When attempting to open a table in phpMyAdmin, you may encounter the following error:

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

This can be a perplexing issue, especially since it originates within the phpMyAdmin interface.

Answer:

The error stems from a mismatch between phpMyAdmin and the underlying PHP version (7.2) on Ubuntu 16.04. To resolve this issue, follow these steps:

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

    sudo nano +613 /usr/share/phpmyadmin/libraries/sql.lib.php
  2. On line 613, replace the following code:

    ((empty($analyzed_sql_results['select_expr']))
     || (count($analyzed_sql_results['select_expr'] == 1)
         && ($analyzed_sql_results['select_expr'][0] == '*')))

    with this corrected code:

    ((empty($analyzed_sql_results['select_expr']))
     || (count($analyzed_sql_results['select_expr']) == 1)
         && ($analyzed_sql_results['select_expr'][0] == '*'))
  3. Additionally, delete the last closing parenthesis on line 614.
  4. Finally, restart the Apache server:

    sudo service apache2 restart

This adjustment will align the count function with the PHP 7.2 syntax, preventing the error from occurring in phpMyAdmin.

The above is the detailed content of When count(): Parameter must be an array or an object that implements Countable Error Occurs in phpMyAdmin, What to Do?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn