Janus13 Posted March 5, 2006 Share Posted March 5, 2006 I've been trying to trace down a strange problem on some of my php pages where the page wouldn't carry variables from a sql query. The variables would end up being the logged on user's variables. My question, is once you set a variable in a page, does it clear when you leave that page or do you have to unset it?Also, if I set a session variable of username, and then define a variable of $username, would those conflict? Quote Link to comment Share on other sites More sharing options...
zq29 Posted March 5, 2006 Share Posted March 5, 2006 It sounds like you might have register_globals switched on in your php.ini file. It should be switched off, at least for security reasons. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 5, 2006 Share Posted March 5, 2006 [!--quoteo(post=351766:date=Mar 5 2006, 06:34 AM:name=Janus13)--][div class=\'quotetop\']QUOTE(Janus13 @ Mar 5 2006, 06:34 AM) [snapback]351766[/snapback][/div][div class=\'quotemain\'][!--quotec--]I've been trying to trace down a strange problem on some of my php pages where the page wouldn't carry variables from a sql query. The variables would end up being the logged on user's variables. My question, is once you set a variable in a page, does it clear when you leave that page or do you have to unset it?[/quote]Variables are only available on the page your set them on. If you want your variables to be available to you on the next page then you'll want to use sessions or transfer the data via the URL, but only if its not personal info being passed over the url. If it is then use sessions.[!--quoteo(post=351766:date=Mar 5 2006, 06:34 AM:name=Janus13)--][div class=\'quotetop\']QUOTE(Janus13 @ Mar 5 2006, 06:34 AM) [snapback]351766[/snapback][/div][div class=\'quotemain\'][!--quotec--]Also, if I set a session variable of username, and then define a variable of $username, would those conflict?[/quote]From what you mentioned here I feel that you register_gloabls set to on which can be a big no no! As this can bring security issues to your site. When you srt register)globals to off you shouldn't get variable conflicts, as you use super global arrays to retrieve your session, post, get data use $_SESSION, $_POST or $_GET and many others. 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.