Notice: unserialize() [function.unserialize]: Error at offset (fix)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Notice: unserialize() [function.unserialize]: Error at offset (fix)

    here is a fix for those who get error like:
    Notice: unserialize() [function.unserialize]: Error at offset
    while trying to unserialize a serialized string.

    fix number 1 (use this function instead of unserialize):
    PHP Code:
    function mb_unserialize($serial_str) { 
    $out preg_replace('!s:(\d+):"(.*?)";!se'"'s:'.strlen('$2').':\"$2\";'"$serial_str ); 
    return 
    unserialize($out); 

    fix number 2 use base64 encoding and decoding of serialized string:
    PHP Code:
    //to safely serialize
    $safe_string_to_store base64_encode(serialize($multidimensional_array));

    //to unserialize...
    $array_restored_from_db unserialize(base64_decode($encoded_serialized_string)); 
    both fixes were taken from php.net and from PHP Serialize() & Unserialize Issues
    Advertise your mobile site for FREE with AdTwirl


    #2
    Solution worked for me.

    Comment


      #3
      The solution looks worked perfect for my script. I wonder you have put your thoughts rights to publish it over here

      thanks

      Comment

      Working...
      X