Home >Backend Development >PHP Tutorial >When count(): Parameter must be an array or an object that implements Countable Error Occurs in phpMyAdmin, What to Do?
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:
Edit the /usr/share/phpmyadmin/libraries/sql.lib.php file using the command:
sudo nano +613 /usr/share/phpmyadmin/libraries/sql.lib.php
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] == '*'))
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!