PDA

View Full Version : not able to use a variable assigned in the url



djgreg
08-01-2004, 04:51 AM
:cry:
I have tried everything but it does not work!!
I have an URl which looks like this:
www.domain.com/pics.php?c=FUE
in the code of pics.php I have the following part where I want to use the $c:
$sql = "SELECT * FROM xyz WHERE code = $c"

On another serevr this works perfectly, but not here at westhost.
I also tried to use $_get["c"]; but this does not work either.

Any suggestions are appreciated :wink:

kind regards
greg

jalal
08-01-2004, 05:07 AM
For security reasons, on Westhost "register_globals=off". On other sites it may be left turned on.

You have two choices, one bad, one good.
Bad choice: turn on register_globals in the php.ini file.
Good choice: access variables using the 'magic' arrays, in your case you want:
$sql = "SELECT * FROM xyz WHERE code ='" . $_GET['c'] . "';";

Look up register_globals in the online docs at php.org for more details, also on the other variables $_POST, $_SERVER etc.

HTH

djgreg
08-01-2004, 05:23 AM
jalal,
thank you very much.
it works now!