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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GET variables not seen by script?

Status
Not open for further replies.

tonedef

Programmer
May 24, 1999
64
US
For some reason my script is not recognizing get variables passed to it. I have tried multiple ways of accessing the GET values and they are always empty.

Ex:
Call page via test.php?value=hello

test.php code
[tt]
<?
include_once(&quot;script.php&quot;);
?>
<html>
<head>
</head>
<body>
...
<?
show();
?>
...
</body>
</html>

script.php code
<?
...
function show()
{
echo &quot;\$HTTP_GET_VARS[\&quot;value\&quot;] = &quot; . $HTTP_GET_VARS[&quot;value&quot;] . &quot;<br />&quot;;
echo &quot;\$_GET[\&quot;value\&quot;] = &quot; . $_GET[&quot;value&quot;] . &quot;<br />&quot;;
echo &quot;\$value = $value<br />&quot;;
}
...
?>

[/tt]

output:
...
$HTTP_GET_VARS[&quot;value&quot;] =
$_GET[&quot;value&quot;] =
$value = ...

PHP Version 4.0.1pl2 running as Apache module on BSDI (So I know the $_GET won't work since it didn't come into being until 4.1 but the others should work (or at least one of them depending on values in php.ini).
Doing the same thing on local test machine PHP v4.1.1 w/ Apache on Win2KPro works fine.

Any thoughts would be greatly appreciated.

Tone
 
Try making HTTP_GET_VARS global in the function using the global keyword.
function show()
{
global $HTTP_GET_VARS;
... //Daniel
 
$_GET will contain the values of the field forms. It is superglobal, so &quot;global&quot; isn't necessary.

Just to ask the dumb question...

The name of the field whose value you are trying to get is actually named &quot;value&quot;, right? Perfection in engineering does not happen when there is nothing more to add. Rather it happens when there is nothing more to take away.
 
&quot;PHP Version 4.0.1pl2 running as Apache module on BSD&quot;.
global is necessary and $_GET didn't exist in that version. //Daniel
 
Oops. Missed that part of the post. Perfection in engineering does not happen when there is nothing more to add. Rather it happens when there is nothing more to take away.
 
Thanks Daniel,

The global did the trick. Thats what I get for developing on a new version than my host...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top