Click to See Complete Forum and Search --> : Help! Query in URL problem!


atr75
02-27-2003, 06:43 PM
I have Apache and PHP4 running on my WinXP machine. Everything works fine:
web pages are served and php scripts are executed correctly. However I have
run into one small problem. Passing arguments to scripts using queries in
the URL (e.g. index.php?id=test) doesn't seem to work. The example I mention
yields an empty &id variable in index.php instead of $id with value 'test'.

Is there anything I need to configure in Apache to enable this? I have been
combing through the manial, but have not been able to find anything.

Help!

Alberto Tobias

cgraz
02-27-2003, 06:45 PM
to grab the value of variable id from the url, use $_GET['id']

Cgraz

atr75
02-27-2003, 06:52 PM
Thanks, that does indeed work!

Is this $_GET['id'] always necessary? I remember being able to read the value of 'id' by using $id directly...

Alberto

cgraz
02-27-2003, 06:55 PM
$_GET is for accessing variables using the GET method.
$_POST is for accessing variables using the POST method.

If you want the short way of accesising the variable, just referring to it as $id for example, then in your php.ini file, set Register Globals to On. It's set to off by default.

Cgraz

atr75
02-27-2003, 07:02 PM
That's it!

Thanks once again! Not only for the info bit also for the speed of your replies!

Alberto