Fatal error: Call to undefined function mb_detect_encoding()
PhpMbstringPhp Problem Overview
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: https://stackoverflow.com/questions/13351635/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:
Php Solutions
Solution 1 - Php
Install the gd library also.
check this link http://www.php.net/manual/en/mbstring.installation.php
Solution 2 - Php
There's a much easier way than recompiling PHP. Just yum install the required mbstring library:
Example: https://stackoverflow.com/questions/10278561/how-to-install-php-mbstring-on-centos-6-2
yum --enablerepo=remi install php-mbstring
Oh, and don't forget to restart apache afterward.
Solution 3 - Php
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
Solution 4 - Php
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
Solution 5 - Php
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.
Solution 6 - Php
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
Solution 7 - Php
For fedora/centos/redhat:
yum install php-mbstring
Then restart apache
Solution 8 - Php
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
Solution 9 - Php
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
Solution 10 - Php
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
Solution 11 - Php
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.
Solution 12 - Php
In case your php version is 7.2:
sudo apt-get install php7.2-mbstring
sudo service apache2 restart
Solution 13 - Php
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)