lordzardeck Posted September 8, 2009 Share Posted September 8, 2009 My object is loaded into a session variable at the end of the script. The next time the script is ran, the object is loaded from the session variable. When it does, I get this error: Fatal error: attackSystem::startAttack() [<a href='attacksystem.startattack'>attacksystem.startattack</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "trainingDummy" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /home/bfwd/public_html/lordsarmy/handlers/attacksystem.php on line 46 What does this mean? Link to comment https://forums.phpfreaks.com/topic/173583-solved-object-serialization/ Share on other sites More sharing options...
TeNDoLLA Posted September 8, 2009 Share Posted September 8, 2009 You must make sure that you have the class defined/included before you start session on this particular page. If session_start() is before the class definition of this object you get this error. Link to comment https://forums.phpfreaks.com/topic/173583-solved-object-serialization/#findComment-914971 Share on other sites More sharing options...
lordzardeck Posted September 8, 2009 Author Share Posted September 8, 2009 Oh, okay. Thanks. I solved the problem though. I needed to call serialize on the object BEFORE placing it in the session variable, and then call unserialize when retrieving it. Link to comment https://forums.phpfreaks.com/topic/173583-solved-object-serialization/#findComment-914977 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.