0

I use php serialize() to serialize a pretty large object, and save it into mysql blob field. when fetched and unserialized i get this error:

unserialize(): Error at offset 65531 of 65535 bytes

I tried overcoming this as suggested in other sources with base64 as in :

//to safely serialize
$safe_string_to_store = base64_encode(serialize($multidimensional_array));

//to unserialize...
$array_restored_from_db = unserialize(base64_decode($encoded_serialized_string));

And still i get same error :

unserialize(): Error at offset 49138 of 49151 bytes

I printed the serialized string (after decoding base64, or after reading from database) and i noticed that it seemed incomplete, this is how it ends :

...a:7:{s:7:"user_id";i:2;s:9:"symbol_id";s:2:"70";s

What could be the reason for that?

UPDATE : this might have something to do with a wrong use of PDO, it seems like i get the correct serialization string before inserting to database...

Ofek Ron
  • 8,354
  • 13
  • 55
  • 103

0 Answers0