Jump to content

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
https://forums.phpfreaks.com/topic/251310-cant-unserialize-objects/
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() )

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.

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.