5

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

rbr94
  • 2,227
  • 3
  • 23
  • 39
Sharik Shaikh
  • 91
  • 1
  • 4

3 Answers3

4

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

Sharik Shaikh
  • 91
  • 1
  • 4
1

Please check you have installed mbstring or iconv PHP extension yet. Because this function just load when you installed one of them. This is code for your case https://github.com/opencart/opencart/blob/master/upload/system/helper/utf8.php

tmquang6805
  • 266
  • 1
  • 4
  • 9
  • I've replaced entire code but the same error message is keep showing in error.log – Sharik Shaikh Sep 23 '16 at 08:58
  • Did you install [mbstring](http://php.net/manual/en/book.mbstring.php) extension? – tmquang6805 Sep 23 '16 at 09:17
  • No I didn't. Because I saw '--enable-mbstring=shared' '--enable-mbregex' this appears in phpinfo(). Does it mean that extention is already installed ? – Sharik Shaikh Sep 23 '16 at 09:57
  • You can check enable mbstring by run this command on console (I run it on linux) `php -m | grep mbstring`. You can follow [this link](http://php.net/manual/en/mbstring.installation.php) for more detail – tmquang6805 Sep 23 '16 at 10:10
  • Thanks for your reply. I ssh into my account and then ran `php -m | grep mbstring` it doesn't show anything. I tried to install mbstring by using this command `yum install php-mbstring` but i get the message `No package php-mbstring available`. May be i'm doing something wrong. I'm sorry and Please correct me. – Sharik Shaikh Sep 23 '16 at 15:56
  • I'm running php 5.6 and easy apache 4 (Don't know how to use it). mbstring is not installed if it is because mbstring then please tell me how can I install mbstring. Thank – Sharik Shaikh Sep 24 '16 at 01:44
0

Install php-mbstring, the only solution