Short Little Test Script Going Wrong with $_GET

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sane993
Forum Newbie
Posts: 22
Joined: Thu Jan 16, 2003 9:44 pm

Short Little Test Script Going Wrong with $_GET

Post by sane993 »

Hello,
I'm just testing this out and cant get it to work.

1st File <test.php>

Code: Select all

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>

<BODY>
<A HREF="test2.php?name=test">Click Me!</A>
</BODY>
</HTML>
2nd File <test2.php>

Code: Select all

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>

<BODY>
<?php
$name = $_HTTP_GET_VARS&#1111;"name"];
echo $name;
?>	
</BODY>
</HTML>
And when test2.php is loaded I get a blank page. Whats going wrong?
btw, PHP Version 4.3.0

Thanks
-sane993
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

just an underscore too much. $HTTP_GET_VARS
somewhere in your webserver's error.log should be an entry "Notice: Undefined variable: _HTTP_GET_VARS in [...]\test2.php on line [...]"

if you're just testing php you might want to set error_reporting = E_ALL and display_errors = On in your php.ini. The latter applies only for the the development system and if you do not want to open the server's error.log ;)
sane993
Forum Newbie
Posts: 22
Joined: Thu Jan 16, 2003 9:44 pm

Post by sane993 »

Thanks Man. :wink:
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Since you're using PHP 4.3.0 you can use $_GET instead of $HTTP_GET_VARS (unless of course you are writing code that needs to run on PHP <= 4.0.6).

For more info:
http://www.php.net/manual/en/language.v ... efined.php

Mac
Beans
Forum Commoner
Posts: 49
Joined: Mon Dec 23, 2002 3:06 am
Location: Manila, Philippines
Contact:

Post by Beans »

I'm using PHP 4.02 (i think... anyway, it's 2 minor versions short of 4.3) and whenever I use the $_GET variable, it returns an Undefined variable....
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

twigletmac wrote:unless of course you are writing code that needs to run on PHP <= 4.0.6
;)
http://www.php.net/manual/en/reserved.v ... iables.get

and

Code: Select all

<?php phpinfo(); ?>
or

Code: Select all

<?php echo phpversion(); ?>
will tell you your version of php.
Post Reply