Posting Serialized Data Not Working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
civil777
Forum Newbie
Posts: 3
Joined: Fri Oct 30, 2009 7:19 am

Posting Serialized Data Not Working

Post by civil777 »

I am trying to send an object from one PHP file to another using POST. I serialize the object and then add slashes. For some reason, only part of the data is getting through. It appears to be a problem with the slashes. Here is the HTML that is generate in the sending PHP file:

<select name="match3"><option value="O:19:\"teacher_student_match\":3:{s:7:\"sess_id\";s:2:\"67\";s:7:\"stud_id\";s:2:\"10\";s:6:\"tut_id\";N;}">Rodriguez, Jorge</option></select>

In the receiving file, I get the following for $_POST['match3']:

O:19:\\

So I am not getting the full string that I am trying to send.

Anyone know what might be going wrong?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Posting Serialized Data Not Working

Post by requinix »

Don't use addslashes to put the serialized data into the <option> - use htmlentities. Then make sure you have magic_quotes (a PHP setting) turned off.
civil777
Forum Newbie
Posts: 3
Joined: Fri Oct 30, 2009 7:19 am

Re: Posting Serialized Data Not Working

Post by civil777 »

Nice! It worked. Thanks.
Post Reply