0

My knowledge of PHP is limited, so I searched the solution for this problem before, but I couldn't fix it.

Upon upgrading PHP to version 7, a script is returning the error:

Call to undefined function mb_convert_encoding()

Which refers to the line:

 echo "<td>" . mb_convert_encoding($row['teste'],'utf-8', 'iso-8859-1') . "</td>";

So, removing the function to:

echo "<td>" . $row['teste'] . "</td>";

Will remove the error, but now the characters are like:

Gest�o or�amental

Is there another function I could use?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • you need to install/enable `mbstring` extension – ArtOsi Dec 19 '17 at 09:50
  • Hi, thanks. How do I do that? Ask the host? Any further specifications? –  Dec 19 '17 at 09:52
  • 1
    Possible duplicate of [mb\_convert\_encoding error: Call to undefined function mb\_convert\_encoding()](https://stackoverflow.com/questions/37441150/mb-convert-encoding-error-call-to-undefined-function-mb-convert-encoding) + [this might also help](https://stackoverflow.com/questions/17204437/fatal-error-call-to-undefined-function-mb-detect-encoding) and [this might also help](https://stackoverflow.com/questions/8266396/mb-convert-encoding-undefined-function-while-mbstring-is-enabled) (Side note: Thumbs down on your research effort!) – caramba Dec 19 '17 at 09:52
  • Well if you don't have rights to modify php config files or install something then probably you need to ask the host – ArtOsi Dec 19 '17 at 09:55

2 Answers2

2

Go to your php.ini file and uncomment extension=php_mbstring.dll.

mb_convert_encoding is also supported in PHP 7, so it should work. It's probably an extension problem.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
pr1nc3
  • 8,108
  • 3
  • 23
  • 36
1

The function mb_convert_encoding() is provided by the Multibyte String (mbstring) PHP extension that apparently is not installed or enabled on your system.

If your PHP runs on Windows then the extension is installed but not enabled. Find the php.ini configuration file (check this answer for guidelines in case you cannot find it), identify the line that reads

;extension=php_mbstring.dll

(the .dll suffix might not be present) and uncomment it (i.e. remove the semicolon from the line start).

On Linux, use the package manager of your distribution (apt, yum, any graphical tool you use to install software, etc), search for php7-mbstring (or just php-mbstring) and install it. There is no need to edit any configuration file, the package manager does all the needed configuration.

No matter the OS, after this step restart the web server.

axiac
  • 68,258
  • 9
  • 99
  • 134