richrock Posted May 22, 2009 Share Posted May 22, 2009 I'm using a $_SESSION array to store some information on images for later comparision, and that's working fine, the remove images from list is fine too, except for one thing: If I have a list of 5 images (the maximum allowed) like this: Image 1 Image abc New jpeg Alt Image Last Image And try to remove any of teh first four images (Image 1 - Alt Image), the unset function just removes the last image. I'm sure I've set this up correctly. But is this code correct? if ($_POST['remove'] != NULL) { if ($_POST['remove'] == 'nothing_a') { $key = '0'; } if ($_POST['remove'] == 'nothing_b') { $key = '1'; } if ($_POST['remove'] == 'nothing_c') { $key = '2'; } if ($_POST['remove'] == 'nothing_d') { $key = '3'; } if ($_POST['remove'] == 'nothing_e') { $key = '4'; } unset($_SESSION['sess_maker'][$key]); unset($_SESSION['sess_location'][$key]); unset($_SESSION['sess_year'][$key]); unset($_SESSION['sess_image'][$key]); unset($_SESSION['sess_type'][$key]); // Code continues using array_merge and array_pop to reset the array with new values } Most examples I've seen use unset like this : unset($_SESSION[$key]); Any ideas would be welcome, TIA Link to comment https://forums.phpfreaks.com/topic/159279-solved-unset-madness/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 22, 2009 Share Posted May 22, 2009 So, what have you done to troubleshoot what it is doing? What value is in $key? What value is in $_POST['remove']? Does the structure of your session variable match $_SESSION['sess_maker'][$key]? Link to comment https://forums.phpfreaks.com/topic/159279-solved-unset-madness/#findComment-840072 Share on other sites More sharing options...
richrock Posted May 26, 2009 Author Share Posted May 26, 2009 turns out that PHP wasn't reading the [$key] value as it was after the $_SESSION['sess_maker'] string... had to work it out another way.. but thanks anyway. I had explored what the session was outputting before and after this part of the script ran, but the whole thing was a bit of a mess and I started from scratch... :-\ Link to comment https://forums.phpfreaks.com/topic/159279-solved-unset-madness/#findComment-842453 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.