Author Topic: undefined function mb_substr()  (Read 6153 times)

shriram

  • Newbie
  • *
  • Posts: 24
    • View Profile
undefined function mb_substr()
« on: October 22, 2008, 06:18:33 am »
A new one today, when i try loging in it shows me this 

Call to undefined function mb_substr() in C:\Program Files\Apache Group\Apache2\htdocs\opengoo\application\helpers\format.php on line 157

shriram

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: undefined function mb_substr()
« Reply #1 on: October 22, 2008, 08:42:57 am »
from the log
#5 ERROR: Error: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: &lt;/versions&gt; in 'C:\Program Files\Apache Group\Apache2\htdocs\opengoo\application\models\versons_feed\VersionsFeed.class.php' on line 113 (error code: 2)

ignacio

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
Re: undefined function mb_substr()
« Reply #2 on: October 22, 2008, 10:33:16 am »
Could you try replacing the truncate function in application/helpers/format.php for this?:

Code: [Select]
function truncate($string, $length, $etc = '...', $charset='UTF-8',
                                  $break_words = false, $middle = false)
{
    if ($length == 0)
        return '';
    if (function_exists('mb_strlen')) {
  $len = mb_strlen($string);
  $lenetc = mb_strlen($etc);
    } else {
    $len = strlen($string);
    $lenetc = strlen($etc);
    }
    if ($len > $length) {
        $length -= min($length, $lenetc);
        if (!$break_words && !$middle) {
        if(function_exists('mb_substr')) {
            $string = preg_replace('/\s+?(\S+)?$/', '', mb_substr($string, 0, $length+1, $charset));
        } else {
        $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
        }
        }
        if(!$middle) {
        if(function_exists('mb_substr')) {
            return mb_substr($string, 0, $length, $charset) . $etc;
        } else {
        return substr($string, 0, $length) . $etc;
        }
        } else {
        if(function_exists('mb_substr')) {
            return mb_substr($string, 0, $length/2, $charset) . $etc . mb_substr($string, -$length/2, $charset);
        } else {
        return substr($string, 0, $length/2) . $etc . substr($string, -$length/2);
        }
        }
    } else {
        return $string;
    }
}

Please tell me if it works for you. Backup the file first so that you can go back if it doesn't do the trick.

Thanks.

shriram

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: undefined function mb_substr()
« Reply #3 on: October 22, 2008, 10:57:37 am »
bingo... it worked .... ;D thanks

shriram

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: undefined function mb_substr()
« Reply #4 on: October 22, 2008, 11:01:06 am »
but on the task comments section i am getting this code
canEdit(logged_user()), true, false); if ($object_links_render != '') { ?>

ignacio

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
Re: undefined function mb_substr()
« Reply #5 on: October 22, 2008, 02:19:23 pm »
Hi shriram,

Remember this post?: http://forums.opengoo.org/index.php?topic=265.msg1051#msg1051

Try undoing that change (putting back the '}' on the code) and tell me how it goes.

shriram

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: undefined function mb_substr()
« Reply #6 on: October 23, 2008, 05:47:09 am »
Its showing the earlier error now..

Parse error: syntax error, unexpected '}' in C:\Program Files\Apache Group\Apache2\htdocs\opengoo\application\views\comment\object_comments.php on line 68