19

When I try and view the wp_posts table in phpmyadmin, I see this error message, but have no idea what it means and have never seen it before.

Can someone help me try and get rid of this somehow?

Warning in ./libraries/sql.lib.php#613
count(): Parameter must be an array or an object that implements Countable

Backtrace

./libraries/sql.lib.php#2128: PMA_isRememberSortingOrder(array)
./libraries/sql.lib.php#2079: PMA_executeQueryAndGetQueryResponse(
array,
boolean true,
string 'afterhours',
string 'wp_posts',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/original/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `wp_posts`',
NULL,
NULL,
)
./sql.php#221: PMA_executeQueryAndSendQueryResponse(
array,
boolean true,
string 'afterhours',
string 'wp_posts',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/original/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `wp_posts`',
NULL,
NULL,
)
Lee
  • 4,187
  • 6
  • 25
  • 71
  • Does this answer your question? [phpmyadmin - count(): Parameter must be an array or an object that implements Countable](https://stackoverflow.com/questions/48001569/phpmyadmin-count-parameter-must-be-an-array-or-an-object-that-implements-co) – miken32 Jan 01 '20 at 17:54

2 Answers2

31

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.
A. MacGillivray
  • 449
  • 4
  • 11
  • I don't have this line. There are no results even for `] == 1`. – brad Sep 10 '18 at 21:52
  • I tried what you have suggested but it does not work for me. – Developer Kwame Feb 15 '20 at 00:53
  • FYI I dug into the github history and found that line in an old version https://github.com/phpmyadmin/phpmyadmin/blame/5a0836262bae583a5ac62c6ec04524e7c8052005/libraries/Sql.php .. if it's not in your version, yours is probably fixed. Frustrating that in this, and a related question https://stackoverflow.com/questions/48001569/phpmyadmin-count-parameter-must-be-an-array-or-an-object-that-implements-co/50536059, people don't report their version of phpMyAdmin. Knowing your Ubuntu or PHP version does not help much :) – Neek Jun 01 '20 at 09:32
15

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()
}
Oscar Otero
  • 325
  • 3
  • 11