53

I receive this error after trying to set up LAMP by following this tutorial, and I find myself receiving the above error after trying to set up phpmyadmin.

Fatal error: Call to undefined function mb_detect_encoding() in C:\WebServer\Apache\htdocs\phpmyadmin\libraries\php-gettext\gettext.inc on line 177

I followed the advice over here: PHP Fatal error when trying to access phpmyadmin mb_detect_encoding, and made those changes.

When I run phpinfo(), I see that support for MySQL and mb_string are enabled as shown below:

mb_string

MySQL

mysqli

2
  • 1
    whats your php version
    – DevZer0
    Jun 20, 2013 at 3:26
  • looks like you need the gd library also
    – DevZer0
    Jun 20, 2013 at 3:27

13 Answers 13

48

Install the gd library also.

check this link http://www.php.net/manual/en/mbstring.installation.php

3
  • 7
    sudo apt-get install php7.0-mbstring && sudo service apache2 restart worked for me
    – h3nr1ke
    Oct 31, 2017 at 14:41
  • 1
    Make sure you install the right version for your php. I somehow managed to install php-mbstring instead of php72-mbstring. So in my case the fix was sudo yum install php72-mbstring
    – Marcin
    Sep 18, 2019 at 4:41
  • Did you mean the mbstring? Because apt install php-gd doesn't help.
    – logicbloke
    Aug 8, 2022 at 11:43
31

There's a much easier way than recompiling PHP. Just yum install the required mbstring library:

Example: How to install PHP mbstring on CentOS 6.2

yum --enablerepo=remi install php-mbstring

Oh, and don't forget to restart apache afterward.

2
  • This also worked in openSuse 13.1 after getting a white homepage for phpMyAdmin: ` yast -i php-mbstring `
    – Semo
    Aug 5, 2014 at 8:49
  • 1
    If you have multiple versions installed on your system, you may need to install the version-specific library, e.g. with sudo apt install php5.6-mbstring.
    – reggie
    Jun 11, 2016 at 7:14
11

Mbstring is a non-default extension. This means it is not enabled by default. You must explicitly enable the module with the configure option.

In case your php version is 7.2:

sudo apt-get install php7.2-mbstring

sudo service apache2 restart

In case your php version is 7.0:

sudo apt-get install php7.0-mbstring

sudo service apache2 restart

In case your php version is 5.6:

sudo apt-get install php5.6-mbstring

sudo service apache2 restart
6

On Windows open the file php.ini and make this changes:

Remove the comment and point to the ext directory

; extension_dir = "./" -> extension_dir = "C:/Php/ext"

Remove the comment of this extensions

  • extension=php_mbstring.dll
  • extension=php_mysqli.dll

Restart apache service

httpd -k restart

3
  • 2
    Also remove the comment (;) from these extensions and extension=php_mysql.dll and extension=php_gettext.dll Jul 29, 2016 at 8:37
  • alternatively you can start APACHE from SERVICE in Windows Jul 29, 2016 at 8:39
  • In ubuntu, I had to uncomment extension=mbstring in my /etc/php/8.1/cli/php.ini, and then it worked just fine.
    – EuripidesL
    Oct 26, 2022 at 20:07
3

When I opened my php.ini file, "extension_dir" line looked like following :

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.

2

Under Windows / WAMP there doesn't seem to be any php_mbstring.dll dependencies on the GD2 extension, the MySQL extensions, nor on external dlls/libs:

deplister.exe ext\php_mbstring.dll

php5ts.dll,OK
MSVCR110.dll,OK
KERNEL32.dll,OK

deplister.exe ext\php_gd2.dll

php5ts.dll,OK
USER32.dll,OK
GDI32.dll,OK
KERNEL32.dll,OK
MSVCR110.dll,OK

Whatever php_mbstring already needs, it's built-in (statically compiled right into the DLL).

Call to undefined function mb_detect_encoding()

This error is also very specific and deterministic...

The function mb_detect_encoding() didn't fail because php_gd, php_mysql, php_mysqli, or another extension was not loaded; it simply was NOT found.

I'm guessing that all the answers that are reported as valid (for Windows / WAMP), that say to load other extensions, to change php.ini extension_dir paths (if this one was wrong to begin with, NO extensions would load), etc, work more due to a) un-commenting the extension = php_mbstring.dll line, or b) restarting Apache or the computer (for changes to take effect).

On Windows, most of the time the problem is that php_mbstring.dll is either:

  • Blocked by Windows. Unblock it by right-clicking it, check Properties.

  • Or PHP can't load php_mbstring.dll due to another version getting loaded (e.g., from some improper PHP DLLs install into C:\Windows\system32), some version mismatch, missing run-time DLLs, etc. Check Apache's and PHP's error log files first for clues.

More in-depth answer here: Call to undefined function mb_detect_encoding

2

For fedora/centos/redhat:

yum install php-mbstring

Then restart apache

1

you should use only english version of phpmyadmin if you are using all languages you should enable all languages mbstring in php.in file.....just search for mbstring in php.in

1

The problem could also be that Apache can't find php.ini If you set PHPIniDir incorrectly. Mine was set to: PHPIniDir "c:/php7" But, the folder is actually just "php" The clue was viewing phpinfo() Which showed: Configuration File (php.ini) Path C:\windows

1

I had the same problem with Ubuntu 17, Ispconfig was not processing the operations queued of any kind and also the server.sh command was not working. I checked and the running PHP version after the OS upgrade was 7.1 so the solution was to type:

apt-get install php7.1-mbstring

and now is everything ok

0

Hope this helps some ppl, I got this error when i added the path and extension to "docref_root" "docref_ext" in my php.ini file, I then commented it out and it was ok, but cant get my help to work now.

0

In case your php version is 7.2:

sudo apt-get install php7.2-mbstring

sudo service apache2 restart
0

PHP.INI XAMP5.6 > In my case, while updating max_ values, I removed ; max_input_time Default Value: -1 (Unlimited)

After undoing everything works normally. ; max_input_time ; Default Value: -1 (Unlimited)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.