Posted By

FreaKzero on 09/01/10


mysql php error at offset serialize

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


serialize and unserialize functions for MYSQL Storage

 / Published in: PHP

In a Project i had to save serialized arrays in a MYSQL Database, when i used that i got a Error Message for no reason (Error at offset XX of XX bytes in...). I wrote this little functions to fix that issue. (I dont recommend to save serialized Arrays in Databases )

  1. function save_serialize($ARR) {
  2. return base64_encode(serialize($ARR));
  3. }
  5. function save_unserialize($STR) {
  6. return unserialize(base64_decode($STR));
  7. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: buzzknow on September 17, 2010

u need to declare new var array before serialize to avoid error offset ..

btw why u put base64_encode?

You need to login to post a comment.