WARNING: Error at offset 761 of 5887 bytes Unserialize PHP string

Friday, 14. June 2013

If you have worked with serialize function in PHP to serialize objects in order to save them in database – and ofcourse if you are reading this post – you have once come across this error

WARNING: Error at offset 761 of 5887 bytes

It’s annoying and always gets me. The main reason for this problem is due to the fact that you have either empty variables in your serialized string or unwanted characters.

The simple solution will be to ensure your encode the string first before you save it to the database.. seems to work well for me (but of course test if for your needs and let us know if it worked for you!)

encode your serialized string with base64

$safeSerializedString = base64_encode(serialize($this->_arrayData));

decode your serialized encoded string with

 $_array_object = unserialize(base64_decode($_row["serialized_column"]));


Leave a Reply

You must be logged in to post a comment.