Archive

Posts Tagged ‘unserialize’

PHP unserialize(): Error at offset – Error Solution

June 2, 2011 1 comment

Some time when we unserialize a variable in PHP, an error come out like

unserialize(): Error at offset

The reason of this error is corruption in “, ‘, :, & ; characters.

Quick Solution

the solution is 2 step based.

  1. While serializing the variable encode it with base64 encoding.

    base64_encode(serialize($data))

  2. While unserializing the variable decode the serialized variable using base64 encoding.

    unserialize(base64_decode($data))