Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Variable

Status
Not open for further replies.

SBuzzT

Programmer
Aug 24, 2005
86
CA
Can someone tell me why a variable I pass in the URL (someurl.com/page.php?a=$b) works if I use it in the top part of the code of the next page, yet will not work further down in my code in the same page. (The value of $b is correct at the top of the code, but does not exist anymore in the code at the end of the page).
 
The problem seems to be in a function I have on the next page. The function can't seem to get the value I am passing. Any way to force the function to grab the value of that variable?
 
The value you're sending over in the url will always be available in the $_GET superglobal, which like its name predicts is available anywhere in the script, even in functions. It is also a best practice to always refer to the variable from url in such a manner. So I suggest you change wherever you call the variable to:
Code:
$_GET['b']
That should work.
 
That's it! Thx a bunch... This was driving me crazy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top