Page 1 of 1
$_GET question
Posted: Tue May 06, 2003 10:55 am
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ї'id'];
echo $id;
echo "<br>";
$id2=$HTTP_GET_VARSї'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.
Posted: Tue May 06, 2003 11:14 am
by Beans
maybe you could try:
//setup.html
<a href="xyz.php?id=123">download</a>
Posted: Tue May 06, 2003 11:23 am
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.
Posted: Tue May 06, 2003 11:32 am
by Beans
daven,
$_REQUEST might not work for him since he's on PHP 4.0.6
Posted: Tue May 06, 2003 12:14 pm
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
Posted: Tue May 06, 2003 12:18 pm
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.
Posted: Tue May 06, 2003 12:30 pm
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:
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
Posted: Tue May 06, 2003 2:11 pm
by o51974
I get it. Thank you for all the help.