Caislean Posted February 27, 2007 Share Posted February 27, 2007 I'm storing session information in an array. (integer)$arrayElement = 0; while($row = mysql_fetch_array($result)) { $_SESSION['eventID[ . $arrayElement]'] = $row['extid']; $arrayElement++; if (debugInfo) echo "Stored Value: " . $_SESSION['eventID[ .$arrayElement]']; } This code gives the proper output of "Stored Value: 0001, Stored Value: 0002, etc..." But then, if I'm outside the while statement and I attempt to retrieve the values, the elements are empty. For example, if I use: for ($counter = ($_SESSION['eventsPerPage'] - $_SESSION['currentEvent']); $counter < $_SESSION['currentEvent']; $counter++) { echo "Stored Value: " . $_SESSION['eventID[ .$arrayElement]']; } It gives the output "Stored Value: , Stored Value: , etc..." Why are the elements suddenly empty after leaving the while statement? Quote Link to comment Share on other sites More sharing options...
Orio Posted February 27, 2007 Share Posted February 27, 2007 Do you have session_start() in the beginning of these two pages? Orio. Quote Link to comment Share on other sites More sharing options...
Caislean Posted February 27, 2007 Author Share Posted February 27, 2007 Yes, I do have a session start in the code. But the code is pretty long, so I thought I'd sum up the problem. If you want to see the full thing just go http://www.phpfreaks.com/forums/index.php/topic,128253.0.html Quote Link to comment Share on other sites More sharing options...
Orio Posted February 27, 2007 Share Posted February 27, 2007 Yeah, I was just making sure. Try replacing all of these: $_SESSION['eventID[ .$arrayElement]'] With these: $_SESSION['eventID'.$arrayElement] Orio. Quote Link to comment Share on other sites More sharing options...
Caislean Posted February 28, 2007 Author Share Posted February 28, 2007 That work perfectly. Thanks, Orio! 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.