robcrozier Posted August 30, 2009 Share Posted August 30, 2009 Hi Guys. Can anyone advise me on the best way of passing an array of objects via form post? I've tried serialising the data, however i'm getting unserialize errors at the other end. I've also tried storing the array as a session, however i then get an incomplete object error at the otger end? I really need to get this working. Any help would be great! Thanks in advance Quote Link to comment Share on other sites More sharing options...
Garethp Posted August 30, 2009 Share Posted August 30, 2009 Pass it as Something1,Something2,Something3,Something4 And then <?php $Array = split($_POST['Thethingwiththesomethings']); ?> Quote Link to comment Share on other sites More sharing options...
robcrozier Posted August 30, 2009 Author Share Posted August 30, 2009 Hi Thanks for the reply. Onlty thing is, when i do that, the object is unknown at the other end and thus i cant access any of it's methods to get the data out of it. Unless you can help me with that error too (the unknown object one), i don't think that's gonna work. Cheers mate! Quote Link to comment Share on other sites More sharing options...
trq Posted August 30, 2009 Share Posted August 30, 2009 The class definition needs to be within scope when you unserialize the object. eg; class.foo.php class foo { public $v; } a.php include 'class.foo.php'; $f = new foo; $f->v = 'hello'; echo '<a href="b.php?obj=' . serialize($f) . '">B</a>'; b.php include 'class.foo.php'; $f = unserialize($_GET['obj']); echo $f->v; Quote Link to comment Share on other sites More sharing options...
robcrozier Posted August 30, 2009 Author Share Posted August 30, 2009 Hey thorpe, Thanks for that! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.