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 Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/ 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 Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679366 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; ?> Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679369 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? Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679372 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.. Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679376 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679378 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>'; Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679380 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) Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679387 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679393 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 Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679395 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... Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679398 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 Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679400 Share on other sites More sharing options...
akitchin Posted October 31, 2008 Share Posted October 31, 2008 what exactly do you mean by "fails?" Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679410 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 Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679412 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 Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679413 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); Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679414 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 Link to comment https://forums.phpfreaks.com/topic/130886-solved-unserilize/#findComment-679731 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.