尝试访问 phpmyadmin mb_detect_encoding 时出现 PHP 致命错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13351635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 05:13:59  来源:igfitidea点击:

PHP Fatal error when trying to access phpmyadmin mb_detect_encoding

phpphpmyadminfatal-error

提问by milan

Not sure what happened, but below is what the log is giving me when trying to access phpmyadmin, please help. Trying to debug a different problem and ran into this. Not really possible to revert back to when it was working.

不知道发生了什么,但下面是尝试访问 phpmyadmin 时日志给我的内容,请帮忙。试图调试一个不同的问题并遇到了这个问题。真的不可能恢复到它工作的时候。

PHP Fatal error: Call to undefined function mb_detect_encoding() in /usr/share/php/gettext/gettext.inc on line 177

PHP 致命错误:在第 177 行调用 /usr/share/php/gettext/gettext.inc 中未定义的函数 mb_detect_encoding()

When trying to go the the site, I get this error, I think it's likely the two errors are related:

尝试访问该站点时,出现此错误,我认为这两个错误可能相关:

Database connection error (1): The MySQL adapter 'mysqli' is not available.

数据库连接错误 (1):MySQL 适配器 'mysqli' 不可用。

回答by Michel Feldheim

First error is caused by php because the extension mbstring is either not installed or not active.

第一个错误是由 php 引起的,因为扩展 mbstring 未安装或未激活。

The second error is output of phpMyAdmin/your site asking you to install / enable the mysqli extension.

第二个错误是 phpMyAdmin/您的站点的输出,要求您安装/启用 mysqli 扩展。

To enable mbstring and mysqli edit your php.ini and add/uncomment the two lines with mbstring.so and mysqli.so on unix or mbstring.dll and mysqli.dll on windows

要启用 mbstring 和 mysqli,请编辑您的 php.ini 并在 unix 上使用 mbstring.so 和 mysqli.so 添加/取消注释两行或在 Windows 上使用 mbstring.dll 和 mysqli.dll

Unix /etc/(phpX/)php.ini

Unix /etc/(phpX/)php.ini

extension=mysqli.so
extension=mbstring.so

Windows PHP installation folder\etc\php.ini

Windows PHP 安装文件夹\etc\php.ini

extension=mysqli.dll
extension=mbstring.dll

Don't forget to restart your webserver after this.

在此之后不要忘记重新启动您的网络服务器。

EDIT: User added he was using redhat in the comments so here's how you install extensions on all CentOS/Fedora/RedHat/Yum based linux distros

编辑:用户在评论中补充说他使用的是 redhat 所以这里是你如何在所有基于 CentOS/Fedora/RedHat/Yum 的 Linux 发行版上安装扩展

sudo yum install php-mysqli
sudo yum install php-mbstring

restart your werbserver
sudo /etc/init.d/httpd restart

you can verify your installation with a little php script in your document root. This lists all settings, versions and active extensions you've installed for php

您可以使用文档根目录中的一个小 php 脚本来验证您的安装。这列出了您为 php 安装的所有设置、版本和活动扩展

test.php

测试文件

<?php
phpinfo();

回答by phpNoob

After reading about the extension_dir = "ext" i added the line to php.ini but didnt work, then started to look apache error log and saw the PHP was in fact unable to find the dll's in the specified directory "ext". I commented the extension_dir line, restarted Apache and looked the error log again, saw that PHP was now looking the dll's in C:/PHP/ext (by default i guess), but since im using other folders, that's not the correct path, so i uncommented the extension_dir line and wrote this:

在阅读了关于 extension_dir = "ext" 的内容后,我将该行添加到 php.ini 但没有用,然后开始查看 apache 错误日志,发现 PHP 实际上无法在指定的目录 "ext" 中找到 dll。我评论了 extension_dir 行,重新启动 Apache 并再次查看错误日志,看到 PHP 现在正在 C:/PHP/ext 中查找 dll(我猜是默认情况下),但是由于我使用其他文件夹,这不是正确的路径,所以我取消了 extension_dir 行的注释并写了这个:

extension_dir = "C:/Apache24/PHP/ext" 

In my configuration that is the correct path to dll's.

在我的配置中,这是 dll 的正确路径。

and of course, uncommented:

当然,未注释:

extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll

Restarted the Apache server and internet browser and now phpMyAdmin works with my mySQL login.

重新启动 Apache 服务器和互联网浏览器,现在 phpMyAdmin 可以与我的 mySQL 登录一起使用。

So, dll's incorrect path and dll's needed commented in php.ini were the problem.

因此,dll 的错误路径和 dll 需要在 php.ini 中注释是问题所在。

Remember to restart Apache and internet browser after editing config files.

编辑完配置文件后记得重启Apache和网络浏览器。

System spec: Windows 7 HB 64bit httpd-2.4.4-win32-ssl_0.9.8.zip php-5.4.16-Win32-VC9-x86.zip phpMyAdmin-4.0.4.1-all-languages.zip mysql-installer-community-5.6.11.0.msi

系统规格:Windows 7 HB 64bit httpd-2.4.4-win32-ssl_0.9.8.zip php-5.4.16-Win32-VC9-x86.zip phpMyAdmin-4.0.4.1-all-languages.zip mysql-installer-community- 5.6.11.0.msi

Hope this help. Thx for your comments too.

希望这有帮助。谢谢你的评论。

回答by Dimitris Kougioumtzis

in ubuntu 16.04 when i tried to connect to phpmyadmin a white blank paged appeared so i ran the above command and phpmyadmin works

在 ubuntu 16.04 中,当我尝试连接到 phpmyadmin 时,出现了一个白色的空白页面,因此我运行了上述命令并且 phpmyadmin 可以正常工作

sudo apt-get install php-mbstring php7.0-mbstring php-gettext

for mysql support install

用于 mysql 支持安装

sudo apt-get install php7.0-mysql

tested in ubuntu 16.04 with php 7 version

在 ubuntu 16.04 和 php 7 版本中测试

回答by Rajeev Ranjan

I had the same problem on my windows7- 32 bit:

我在 windows7-32 位上遇到了同样的问题:

1."PHP Fatal error: Call to undefined function mb_detect_encoding() in /usr/share/php/gettext/gettext.inc on line 177"

1.“PHP 致命错误:在第 177 行调用 /usr/share/php/gettext/gettext.inc 中未定义的函数 mb_detect_encoding()”

when i opened my php.ini file , "extension_dir" line looked like following :

当我打开 php.ini 文件时,“extension_dir”行如下所示:

extension_dir = "C:/wamp/bin/php/php5.4.16/ext/"

which i changed to :

我改为:

extension_dir = "C:\wamp\bin\php\php5.4.16\ext\"

and it worked.

它奏效了。

回答by Koen.

It looks like your PHP installation does not have the mbstring extensionand the mysqli adapter extensioninstalled.

看起来您的 PHP 安装没有安装mbstring 扩展mysqli 适配器扩展

Please check your phpinfo();or run php -i | grep 'mbstring\|mysqli'in a terminal.

请检查您的phpinfo();php -i | grep 'mbstring\|mysqli'在终端中运行。

回答by Fernando Maffeis

In php.ini, I had to change

php.ini,我不得不改变

extension_dir = "ext"

to

extension_dir = "C:/PHP/ext"

as my PHP was installed in C:\PHP. I had to use /instead of \, and then it worked.

因为我的 PHP 安装在C:\PHP. 我不得不使用/而不是\,然后它起作用了。

Also uncomment mbstrings, mysqliand mysqlextensions.

还要取消mbstringsmysqlimysql扩展。

回答by Harikrishnan

Recompile PHP with mbstring.

用 mbstring 重新编译 PHP。

./configure --enable-http --with-apxs2 --with-mysql --with-gd --with-curl --with-mbstring

./configure --enable-http --with-apxs2 --with-mysql --with-gd --with-curl --with-mbstring

make 

make install

回答by user2314737

What helped me (using XAMPP on Windows) was to:

帮助我(在 Windows 上使用 XAMPP)的是:

  • make sure that my path included the correct path for PHP (I had two PHP installations, one under c:\phpand the XAMPP installation in c:\xampp\phpwhich was the one I wanted to use)
  • check that the lines
    extension_dir="C:\xampp\php\ext"
    extension=php_mbstring.dll
    extension=php_exif.dll ; Must be after mbstring as it depends on it
    were uncommented in the php.ini file (i.e. no ;at the beginning)
  • restart the Apache server
  • last but not least, clear the cache when reloading the page http://localhost/phpmyadmin/(for instance with Ctrl-F5 in Chrome)
  • 确保我的路径包含正确的 PHP 路径(我有两个 PHP 安装,一个在下面c:\php,而 XAMPP 安装 c:\xampp\php是我想使用的那个)
  • 检查
    extension_dir="C:\xampp\php\ext"
    extension=php_mbstring.dll
    extension=php_exif.dll ; Must be after mbstring as it depends on it
    php.ini 文件中的行是否已取消注释(即;开头没有)
  • 重启 Apache 服务器
  • 最后但并非最不重要的一点是,在重新加载页面时清除缓存http://localhost/phpmyadmin/(例如在 Chrome 中使用 Ctrl-F5)

回答by amitgoswami

I tried on Windows and I was getting same issue after enabling this in PHP installation folder\etc\php.ini:

我在 Windows 上尝试过,在启用此功能后遇到了同样的问题PHP installation folder\etc\php.ini

extension=mysqli.dll 
extension=mbstring.dl

You should also enable the following in the ini file:

您还应该在 ini 文件中启用以下内容:

extension_dir = "ext"

phpMyadmin is working now!

phpMyadmin 正在工作!

回答by shashikanth

In windows 2008 Server.

在 Windows 2008 服务器中。

i removed ";" in front of extension=php_mbstring.dll in php.ini file and it worked... i followed below link...

我删除了 ”;” 在 php.ini 文件中的 extension=php_mbstring.dll 前面,它起作用了......我按照下面的链接......

https://bugs.php.net/bug.php?id=64965

https://bugs.php.net/bug.php?id=64965