49

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

Community
  • 1
  • 1
Louis93
  • 3,609
  • 8
  • 43
  • 86

11 Answers11

45

Install the gd library also.

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

Kermit
  • 32,563
  • 10
  • 80
  • 117
Jibu K
  • 476
  • 5
  • 3
  • 3
    sudo apt-get install php7.0-mbstring && sudo service apache2 restart worked for me – h3nr1ke Oct 31 '17 at 14:41
  • 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 '19 at 04:41
29

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.

Community
  • 1
  • 1
Phil LaNasa
  • 2,703
  • 1
  • 22
  • 16
  • This also worked in openSuse 13.1 after getting a white homepage for phpMyAdmin: ` yast -i php-mbstring ` – Semo Aug 05 '14 at 08: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 '16 at 07:14
9

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.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
BSB
  • 1,670
  • 11
  • 20
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

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.

Tunaki
  • 116,530
  • 39
  • 281
  • 370
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

rightstuff
  • 5,994
  • 29
  • 20
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

For fedora/centos/redhat:

yum install php-mbstring

Then restart apache

user3413723
  • 8,503
  • 4
  • 47
  • 56
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

ironarm
  • 417
  • 4
  • 11
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

sorak
  • 2,587
  • 2
  • 14
  • 24
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.

Vasko
  • 259
  • 3
  • 13