skyrice Posted September 25, 2006 Share Posted September 25, 2006 Hi there, I'm new here. Anyhow, here's my dilemma:<?php session_start(); include 'database.inc'; $query = mysql_query("SELECT * FROM `table`"); $_SESSION['mysql_result_array'] = mysql_fetch_assoc($query); print_r($_SESSION['mysql_result_array']); /* This will print out: Array ( [key] => value [key] => value [key] => value ) As I would expect it to. */?>Now guess what happens when I get to another page and do this:<?php session_start(); print_r($_SESSION['mysql_result_array']); /* This prints out simply: Resource id #3 */?>I've tried even copying the array to a session variable key by key and it still gets destroyed when I move off the page. The reason I need this array in a session variable is because the next page is going to clear the data from the table, but I still need the data that used to be there in order to fill in some forms.The session variable is perfectly set to the right array when I'm on the page, and then when you move off of that page it gets destroyed. This is so frustrating... Nothing is touching the array btw... Quote Link to comment Share on other sites More sharing options...
skyrice Posted September 25, 2006 Author Share Posted September 25, 2006 Just for fun I ran the basic concept code that I originally posted and it worked fine. I then went and rechecked to make sure that absolutely nothing was messing with my session variables and confirmed it; it's not hard to see. There are only 3 references to $_SESSION between both scripts. I don't see how this is happening... =( Quote Link to comment Share on other sites More sharing options...
tomfmason Posted September 25, 2006 Share Posted September 25, 2006 I think that [url=http://us3.php.net/manual/en/function.session-write-close.php]session_write_close()[/url] maybe the answer to your problems.Let us know if that fixes it..Good luck,Tom Quote Link to comment Share on other sites More sharing options...
skyrice Posted September 25, 2006 Author Share Posted September 25, 2006 Stuck that right underneath the $_SESSION variable assignment, then did print_r to make sure the right information was stored in the variable. Also did session_write_close() immediately after session_start() on the next page; same result. =(How is the variable changing when nothing is changing it? Quote Link to comment Share on other sites More sharing options...
skyrice Posted September 26, 2006 Author Share Posted September 26, 2006 I finally figured it out today. The people at my work have REGISTER_GLOBALS turned on. The session variable I was using has the same name as a non-session variable that is being assigned within the script and apparently it overwrites the $_SESSION variable of the same name as well. I didn't know that, nor did I know that REGISTER_GLOBALS was on...Bunch of bums over here...:-\ Quote Link to comment Share on other sites More sharing options...
Jenk Posted September 26, 2006 Share Posted September 26, 2006 You'll be glad to see PHP6 then :) (removing register_globals) 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.