Jump to content

Can't unserialize objects?


Ninjakreborn

Recommended Posts

I took an object, and saved it into a database serialized.

 

$object_here = serialize($theobject);

Then later on, I go and I get that data from a database, and try to unserialize it..

 

$objecthere = unserialize($row->theobject)

 

And it throws the following error...any advice?

Warning: unserialize() [function.unserialize]: Node no longer exists in /path/to/file on line 20

Link to comment
Share on other sites

1.) Make sure that the database field is large enough to hold the serialized array. Serialized data is very space-inefficient in PHP, and many DBs (like MySQL) will silently truncate field values that are too long.

 

2.) Make sure that you are not serializing a resource id / object (because they can't be serialized)

 

3.) When saving serialized data, don't try and do anything to it other than escaping ( mysql_real_escape_string() )

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.