我已经上传了备份到一个表,打开表我看到这个:

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

Backtrace

./libraries/sql.lib.php#2038: PMA_isRememberSortingOrder(array)
./libraries/sql.lib.php#1984: PMA_executeQueryAndGetQueryResponse(
array,
boolean true,
string 'alternativegirls',
string 'tgp_photo',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `tgp_photo`',
NULL,
NULL,
)
./sql.php#216: PMA_executeQueryAndSendQueryResponse(
array,
boolean true,
string 'alternativegirls',
string 'tgp_photo',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `tgp_photo`',
NULL,
NULL,
)
./index.php#53: include(./sql.php)

在phpMyAdmin……

PHP是7.2,服务器是Ubuntu 16.04,昨天安装的。

我看到一些人在他们的代码中有这个错误,但我没有发现任何人在phpMyAdmin中收到它…

我该怎么办?这是我的错误吗?phpmyadmin错误?等待更新?回到PHP 7.1?


当前回答

为我工作。Ubuntu 18.04

sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php

查找文件中的count($analyzed_sql_results['select_expr']代码。您可以在第613行得到这一点。

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

只需用代码替换:

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

保存文件并重新加载PhpMyAdmin。

完成了! !

其他回答

我认为最好的选择是将Phpmyadmin更新到一个已经修复了这个问题的版本。

在它作为deb发布之前,你可以像@crimson-501那样做,我将在下面复制:

Your first step is to install PMA (phpMyAdmin) from the official Ubuntu repo: apt-get install phpmyadmin. Next, cd into usr/share directory: cd /usr/share. Third, remove the phpmyadmin directory: rm -rf phpmyadmin. Now we need to download the latest PMA version onto our system (Note that you need wget: apt-get install wget): wget -P /usr/share/ "https://files.phpmyadmin.net/phpMyAdmin/4.9.4/phpMyAdmin-4.9.4-english.zip" Let me explain the arguments of this command, -P defines the path and "the link.zip" is currently (7/17/18) the latest version of PMA. You can find those links HERE. For this next step you need unzip (apt-get install unzip): unzip phpMyAdmin-4.9.4-english.zip. We just unzipped PMA, now we will move it to it's final home. Lets use the cp (copy) command to move our files! Note that we have to add the -r argument since this is a folder. cp -r phpMyAdmin-4.9.4-english phpmyadmin. Now it's time to clean up: rm -rf phpMyAdmin-4.9.4-english.

继续阅读!

在登录到PMA之后,您现在可能会注意到两个错误。

the configuration file now needs a secret passphrase (blowfish_secret). phpmyadmin
The $cfg['TempDir'] (./tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.

然而,这些问题相对容易解决。对于第一个问题,你所要做的就是抓取你选择的编辑器,编辑/usr/share/phpmyadmin/config.inc.php,但有一个问题,我们删除了它!没关系,你要做的就是:cd /usr/share/phpmyadmin & cp config.sample.inc.php config.inc.php。

现在我们将添加河豚秘密!Nano config.inc.php并从该页底部附近复制动态生成的秘密:https://www.question-defense.com/tools/phpmyadmin-blowfish-secret-generator。

示例phpMyAdmin Blowfish秘密变量入口:

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = '{^QP+-(3mlHy+Gd~FE3mN{gIATs^1lX+T=KVYv{ubK*U0V'; 
/* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

现在保存并关闭文件。

现在我们将为PMA创建一个tmp目录:mkdir tmp & chown -R www-data:www-data /usr/share/phpmyadmin/tmp。最后一个命令允许Apache web服务器拥有tmp目录并编辑它的内容。

对于我的phpmyadmin版本(4.6.6deb5),我找到了第613行,并意识到count()括号没有正确关闭。要在下次发布之前暂时修复这个问题,只需更改:

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

to:

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

在Ubuntu 18.04上,使用MariaDb和Nginx,我通过更新文件/usr/share/phpmyadmin/libraries/sql.lib.php解决了这个问题,如下:

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

@Nguyen提到的答案抛出了一个500错误,说:

FastCGI sent in stderr: "PHP message: PHP Parse error:  syntax error, unexpected ')', expecting ';' in /usr/share/phpmyadmin/libraries/sql.lib.php on line 614"

由于conf文件中的代码错误可能会有所不同(@Jacky Nguyen vs @ĦΔŇĐŘΔ ŇΔҜҜΔ answers),一般解决方案的答案是 A)修正conf文件中的条件逻辑使之有意义 (x)或b)安装正确的/当前phpmyadmin

至于a)

open the file with error code For the terminal people: sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php For the regular folks: sudo gedit /usr/share/phpmyadmin/libraries/sql.lib.php find the condition - basically search for $analyzed_sql_results['select_expr'] now the logic should be to check whether this sub array is empty, or, whether it has just 1 element with a value "* so basically the block between && $analyzed_sql_results['select_from']and && count($analyzed_sql_results['select_tables']) == 1 should look something like this

& & ( Empty ($analyzed_sql_results['select_expr']) //子数组为空, | | / /, ( (count($analyzed_sql_results['select_expr']) == 1) //只有一个元素 && //和同时 ($analyzed_sql_results['select_expr'][0] == '*') // 1元素值为"*" ) )

这是一个很好的例子,为什么缩进和美化你的代码,如果它将缩进正确,我相信这永远不会发生,或者至少,会更容易找到。

这在PHPMyAdmin的后续版本中得到了修复。Ubuntu 18.04.2的Ubuntu软件库的版本是4.6.6.5,而它们目前的版本是4.9.0.1。更新PHPMyAdmin安装可以解决这个问题,但是可能比仅仅编辑一行代码风险更大。下面是我在我的Ubuntu服务器上是怎么做的。对于所有操作系统,步骤本质上是相同的(只是路径不同)。

下载PHPMyAdmin。

wget https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.zip
unzip phpMyAdmin-4.9.0.1-all-languages.zip

备份旧的PHPMyAdmin安装。

cp -r /usr/share/phpmyadmin ~/phpmyadmin-backup

在旧的PHPMyAdmin上删除新的PHPMyAdmin

cd phpMyAdmin-4.9.0.1-all-languages
rm -r /usr/share/phpmyadmin/doc/html
cp -R * /usr/share/phpmyadmin/

验证它是否有效。如果没有,那么……您有备份,因此恢复它并手动编辑故障行。根据我个人的经验,我发现4.6.6.5版本不仅漏洞百出,而且与新的4.9.0.1相比速度也慢得令人难以置信。对于我认为是“WordPress”质量的东西来说,速度的提高是纯粹的魔法。