Jump to content

Can't unserialize objects?


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

I am taking an XML feed, and turning it into an array with


$response = simplexml_load_string($results);


Then I am turning the $response->actions which is an object, into a serialized string.  Then saving it into a database table, as a varchar 225...

it's not a large array though.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • 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.