$_GET question

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
o51974
Forum Newbie
Posts: 9
Joined: Tue May 06, 2003 10:55 am

$_GET question

Post by o51974 »

hi all,

I have set up a link as follows:

Code: Select all

//setup.html
<a href=xyz.php?id=123>download</a>
When user click this link, I have

Code: Select all

<?php
//xyz.php
	$id=$_GET&#1111;'id'];
	echo $id;
	echo "<br>";
	$id2=$HTTP_GET_VARS&#1111;'id'];
	echo $id2;
?>
For some reason, both of them are not echoed. I checked the php.ini and the register_globals=On. The PHP ver is 4.0.6. I'd appreciate any idea.
Beans
Forum Commoner
Posts: 49
Joined: Mon Dec 23, 2002 3:06 am
Location: Manila, Philippines
Contact:

Post by Beans »

maybe you could try:

//setup.html
<a href="xyz.php?id=123">download</a>
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

Beans is correct. You need quotes around your href info.

If you still do not get any results, try print_r($_REQUEST) and print_r($_SERVER['QUERY_STRING']) to see if you are getting anything passed.
Beans
Forum Commoner
Posts: 49
Joined: Mon Dec 23, 2002 3:06 am
Location: Manila, Philippines
Contact:

Post by Beans »

daven,

$_REQUEST might not work for him since he's on PHP 4.0.6
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

$_GET['id'] definitely won't work as it is only available for PHP version 4.1 or higher.

Check the output of:

Code: Select all

echo '<pre>';
print_r($HTTP_GET_VARS);
echo '</pre>';
to see what is getting passed - also make sure that you can see the query string in the URL in the Address bar of your browser.

Mac
o51974
Forum Newbie
Posts: 9
Joined: Tue May 06, 2003 10:55 am

Post by o51974 »

I do have the quote but I just forgot to put in. Sorry about the confustion.

At 4.0.6, do I have to use $HTTP_*_VARS instead of $_POST? Is there a way for me to activate the shorter alias?

Thank you for all the reply.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

o51974 wrote:At 4.0.6, do I have to use $HTTP_*_VARS instead of $_POST?
Yes
o51974 wrote:Is there a way for me to activate the shorter alias?
Not to have them automatically assigned, no (well not unless you upgraded your PHP version). You could do things like:

Code: Select all

$_POST = $HTTP_POST_VARS;
at the top of your scripts but the $_POST array in this case will just be a copy of $HTTP_POST_VARS and will not have the special (autoglobal) properties of $_POST in PHP 4.1 and up.

Mac
o51974
Forum Newbie
Posts: 9
Joined: Tue May 06, 2003 10:55 am

Post by o51974 »

I get it. Thank you for all the help.
Post Reply