I have made two classes. One is a guestbook class, the other is an entry class for each entry in the guestbook. The reason I did this was so that I could serialize them and essentially serialize the guestbook, unserialize, alter, re-serialize, and read and whatnot.
Maybe I don't understand the purpose of serializing, but this doesn't work. For the sign.php file, I can write out the guestbook object to a file, and then even reread it, alter, and re-serialize it with additional entries. When I go to view.php, however, there is this cryptic error message:
O:9:"guestbook":2:{s:5:"count";i:2;s:7:"entries";a:2:{i:0;O:5:"entry":4:{s:9:"firstname";s:3:"Sam";s:8:"lastname";s:7:"Goldman";s:5:"email";s:18:"samgoldman@mac.com";s:7:"comment";s:23:"This is the first post!";}i:1;O:5:"entry":4:{s:9:"firstname";s:3:"Sam";s:8:"lastname";s:7:"Goldman";s:5:"email";s:18:"samgoldman@mac.com";s:7:"comment";s:21:"This is another post!";}}}
Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition guestbook of the object you are trying to operate on was loaded before the session was started in /Users/sgoldman/Sites/php/guestbook_OO/view.php on line 15
Obviously, the serialized guestbook is there, but there is this whole 'session' twist that I don't really understand.
Can I "freeze-dry" objects like this?
Thanks,
Sam