Fatal error: Call to undefined function utf8_substr() Opencart

Sharik Shaikh picture Sharik Shaikh · Sep 23, 2016 · Viewed 7.2k times · Source

My site was working fine from last 2 3 months but now it shows 500 Server error message. Then I saw the error.log file it says that

PHP Fatal error: Call to undefined function utf8_substr() in public_html/catalog/model/tool/image.php on line 11

And the code at the given location is:

$new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;

Then I thought may be its because of cache and then I cleared the cache and still gets the same error message. I was looking for solution on google and I found few solution like Clearing cache, Check if startup.php or utf8.php is missing or not but file is on the correct place. It is on production env and site is down from last two days.

Please tell me a solution for this problem.

I'm running Opencart version 2.0.3.1

Thanks in advance

Answer

Sharik Shaikh picture Sharik Shaikh · Sep 24, 2016

I found the solution. My site was missing mbstring extension. yum install mbstring wasn't working on my server because it was named ea-php56-php-mbstring-5.6.26-1.1.2.cpanel.x86_64. I installed this and my website is working again. If you are also having same problem. Then please ssh into your site and check if mbstring is installed you can check that by running php -m | grep mbstring it will not return anything if mbstring is not installed but if extension is installed then it will return mbstring. If mbstring is missing then You can run this command yum search mbstring it will search extentions with mbstring word. Then run this command yum install NAME_OF_FILE. Replace NAME_OF_FILE with the name of the mbstring file. then follow instruction and once the installation is done. You can cross check if mbstring is installed by running php -m | grep mbstring command. It was so helpful in my case. I'm sorry if I didn't explain it properly. Thank you tmquang6805