dropfaith Posted October 31, 2008 Share Posted October 31, 2008 the top one works the bottom doesnt any obvious reason why? $Archetypes1 = ($row->Archetypes); $Archetypes2 = unserialize($Archetypes1); $Scenes1 = ($row->Scenes); $Scenes2 = unserialize($Scenes1); ive echoed both Scenes1 and Scenes2 Scenes1 (makes the serlized array display on screen Scenes2 just prints the word array Quote Link to comment Share on other sites More sharing options...
rhodesa Posted October 31, 2008 Share Posted October 31, 2008 that means the value that is being unserialized is an array. print it with print_r() instead Quote Link to comment Share on other sites More sharing options...
dropfaith Posted October 31, 2008 Author Share Posted October 31, 2008 its part of a much bigger code im not directly echoing them out that was just for debugging <?php //Create the array of selected values $Scenes1 = ($row->Scenes); $Scenes2 = unserialize($Scenes1); $checkOptions = array ( 'Having a romantic dinner by candlelight', 'I am spanked because I have been a naughty boy or girl', 'A stranger walks into my bedroom and finds me playing with myselfI am sold on a slave market', 'I am a foot slave, forced to care for my Mistress feet', 'I am a piece for furniture, only useful as a tabletop, etc', 'I am forced to behave as a gender I am not', 'I am a dirty slut and must be punished', 'I am used as a slave in public', 'I am used as a slave in private', 'I am ordered to please others', 'I am a little schoolgirl or schoolboy', 'I am sitting/kneeling at my Mistress feet', 'I am are tied and teased', 'I am grabbed by the hair and dragged into the bedroom', 'I am used as a dog, pony or pet', 'I am verbally humiliated', 'I am tied, gagged and blindfolded and left alone', 'I am tied, gagged, blindfolded and thoroughly whipped', 'My physical limits are tested and stretched', 'My mental limits are tested and stretched', 'I am a total slave every day of the week' ); foreach ($checkOptions as $option) { $selected = (in_array($option, $Scenes2))?' checked="checked"':''; echo "<input type=\"checkbox\" name=\"Scenes[]\" value=\"$option\"$selected />$option<br />\n"; } echo $Scenes1; echo "<br />"; echo $Scenes2; ?> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted October 31, 2008 Share Posted October 31, 2008 the script you have looks fine...minus the "echo $Scenes2" at the end. what are you trying to accomplish there? Quote Link to comment Share on other sites More sharing options...
dropfaith Posted October 31, 2008 Author Share Posted October 31, 2008 it is supposed to populate checkboxes from a database i have like 10 of these and this is the only one that fails.. Quote Link to comment Share on other sites More sharing options...
dropfaith Posted October 31, 2008 Author Share Posted October 31, 2008 works i cant see a difference <?php //Create the array of selected values $Archetypes1 = ($row->Archetypes); $Archetypes2 = unserialize($Archetypes1); $checkOptions = array ( 'Soldiers, marines, paratroopers', 'Sailors, coast guard, merchant marine', 'Airmen, pilots', 'Policewomen, security people', 'Truck drivers', 'Firemen', 'Executioners', 'Nurses, doctors', 'Prostitutes, tramps', 'Cruel/abusive women', 'Cowgirl', 'Surfers, life guards', 'Biker chicks', 'Warrior/Wrestler', 'Royalty, nobility', 'Business people. managers, the boss', 'Divas', 'Teachers', 'Daddy', 'Mommy' ); foreach ($checkOptions as $option) { $selected = (in_array($option, $Archetypes2))?' checked="checked"':''; echo "<input type=\"checkbox\" name=\"Archetypes[]\" value=\"$option\"$selected />$option<br />\n"; } ?> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted October 31, 2008 Share Posted October 31, 2008 what is the output of the following: $Scenes1 = ($row->Scenes); $Scenes2 = unserialize($Scenes1); print '<pre>'.print_r($Scenes2,1).'</pre>'; Quote Link to comment Share on other sites More sharing options...
dropfaith Posted October 31, 2008 Author Share Posted October 31, 2008 Array ( [0] => I am spanked because I have been a naughty boy or girl [1] => A stranger walks into my bedroom and finds me playing with myself ) (edited by kenrbnsn to add tags) Quote Link to comment Share on other sites More sharing options...
rhodesa Posted October 31, 2008 Share Posted October 31, 2008 the following works fine for me. the only thing i did was manually set the value for $Scenes2 and split two items where you forgot a ',' on line two of the big array <?php //Create the array of selected values //$Scenes1 = ($row->Scenes); //$Scenes2 = unserialize($Scenes1); $Scenes2 = array( 'I am spanked because I have been a naughty boy or girl', 'A stranger walks into my bedroom and finds me playing with myself' ); $checkOptions = array ( 'Having a romantic dinner by candlelight', 'I am spanked because I have been a naughty boy or girl', 'A stranger walks into my bedroom and finds me playing with myself','I am sold on a slave market', 'I am a foot slave, forced to care for my Mistress feet', 'I am a piece for furniture, only useful as a tabletop, etc', 'I am forced to behave as a gender I am not', 'I am a dirty slut and must be punished', 'I am used as a slave in public', 'I am used as a slave in private', 'I am ordered to please others', 'I am a little schoolgirl or schoolboy', 'I am sitting/kneeling at my Mistress feet', 'I am are tied and teased', 'I am grabbed by the hair and dragged into the bedroom', 'I am used as a dog, pony or pet', 'I am verbally humiliated', 'I am tied, gagged and blindfolded and left alone', 'I am tied, gagged, blindfolded and thoroughly whipped', 'My physical limits are tested and stretched', 'My mental limits are tested and stretched', 'I am a total slave every day of the week' ); foreach ($checkOptions as $option) { $selected = (in_array($option, $Scenes2))?' checked="checked"':''; echo "<input type=\"checkbox\" name=\"Scenes[]\" value=\"$option\"$selected />$option<br />\n"; } ?> Quote Link to comment Share on other sites More sharing options...
aximbigfan Posted October 31, 2008 Share Posted October 31, 2008 Array ( [0] => I am spanked because I have been a naughty boy or girl [1] => A stranger walks into my bedroom and finds me playing with myself ) (edited by kenrbnsn to add tags) lol wut? Unserialize is quite easy to understand. If you stick an array into serialize() you will get a string. unserialize that string as a var ($var = unser...) and you get that same array structure under the new variable name. Chris Quote Link to comment Share on other sites More sharing options...
rhodesa Posted October 31, 2008 Share Posted October 31, 2008 Array ( [0] => I am spanked because I have been a naughty boy or girl [1] => A stranger walks into my bedroom and finds me playing with myself ) (edited by kenrbnsn to add tags) lol wut? ...yeah...it's taken all of my energy not to comment about the values in the array... Quote Link to comment Share on other sites More sharing options...
dropfaith Posted October 31, 2008 Author Share Posted October 31, 2008 yea sorry about those im working for a pro Dominatrix as a client its been a trippy job so far you should see the whole form if you think this is bad hrmm when i use your code it works but when i get the array from the db it fails odd Quote Link to comment Share on other sites More sharing options...
akitchin Posted October 31, 2008 Share Posted October 31, 2008 what exactly do you mean by "fails?" Quote Link to comment Share on other sites More sharing options...
dropfaith Posted October 31, 2008 Author Share Posted October 31, 2008 no errors just doesnt select the two checkboxes Quote Link to comment Share on other sites More sharing options...
dropfaith Posted October 31, 2008 Author Share Posted October 31, 2008 odd i didnt really change anything but its working now $Scenes1 = ($row->Scenes); $Scenes2 = unserialize($Scenes1); works all of a sudden Quote Link to comment Share on other sites More sharing options...
rhodesa Posted October 31, 2008 Share Posted October 31, 2008 glad it's working...just a note, unless you specifically need the serialized version in a variable, you should save memory and just use one variable: $Scenes = unserialize($row->Scenes); Quote Link to comment Share on other sites More sharing options...
aximbigfan Posted October 31, 2008 Share Posted October 31, 2008 Array ( [0] => I am spanked because I have been a naughty boy or girl [1] => A stranger walks into my bedroom and finds me playing with myself ) (edited by kenrbnsn to add tags) lol wut? ...yeah...it's taken all of my energy not to comment about the values in the array... I found this especially hilarious: [0] => I am spanked because I have been a naughty boy or girl Chris 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.