Jump to content

Recommended Posts

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?
Link to comment
https://forums.phpfreaks.com/topic/4128-php-variables-sticking/
Share on other sites

[!--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.
Link to comment
https://forums.phpfreaks.com/topic/4128-php-variables-sticking/#findComment-14423
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.