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):
fix number 2 use base64 encoding and decoding of serialized string:
both fixes were taken from php.net and from PHP Serialize() & Unserialize Issues
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);
}
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));
Comment