sql – Parameter must be an array or an object that implements Countable in phpmyadmin

sql – Parameter must be an array or an object that implements Countable in phpmyadmin

This appears to be a duplicate of phpmyadmin – count(): Parameter must be an array or an object that implements Countable

According to the top answer on the linked post, it looks like there may be an error in the ./libraries/sql.lib.php that is causing the code to attempt a count() function on something other than an array (or an object that implements Countable). To fix it (according to the linked response):

Edit file /usr/share/phpmyadmin/libraries/sql.lib.php and replace

(count($analyzed_sql_results[select_expr] == 1) 

With:

(count($analyzed_sql_results[select_expr]) == 1

This works because:

  • count cannot be performed on a non-array (hence your error, Parameter must be an array or an object that implements Countable)
  • == 1 in count() is an equivalency test, not an array
  • removing == 1 from count() leaves a count(array) function, which works.

I solved the problem by validating if it really is an array using the is_array() function like this:

if (is_array($yourArray)) {
    //Your count()
}

sql – Parameter must be an array or an object that implements Countable in phpmyadmin

Leave a Reply

Your email address will not be published.