isset fails, getenv succeeds (Apache configuration problem?)

isset fails, getenv succeeds (Apache configuration problem?)

am 04.09.2007 01:32:25 von Adam Baker

I'm not sure whether the following is a problem with PHP or my Apache
server. Minimal example:

if (isset($dummy))
echo "Set.";
else
echo "Not set.";

echo "\n
".getenv("QUERY_STRING");
?>

With this URL:
http://localhost/minimal.php?dummy=5

Produces:
Not set.
dummy=5


isset works as expected when I run this on a different server (Windows
something, with an older PHP version, sorry I don't know the
specifics). Can anybody say whether this is a problem with my PHP
installation or my Apache installation?

Thanks,
Adam

Re: isset fails, getenv succeeds (Apache configuration problem?)

am 04.09.2007 01:40:49 von Andy Hassall

On Mon, 03 Sep 2007 23:32:25 -0000, Adam Baker wrote:

>I'm not sure whether the following is a problem with PHP or my Apache
>server. Minimal example:
>
> >if (isset($dummy))
[snip]
>
>With this URL:
>http://localhost/minimal.php?dummy=5
>
>isset works as expected when I run this on a different server (Windows
>something, with an older PHP version, sorry I don't know the
>specifics). Can anybody say whether this is a problem with my PHP
>installation or my Apache installation?

It's really a problem with your code, see: http://uk3.php.net/register_globals

You're using a feature that was disabled by default about 5 years ago for
several good reasons. You can re-enable it, but that's not a good idea; see
previous link for how.

See also http://uk3.php.net/manual/en/language.variables.external.php

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

Re: isset fails, getenv succeeds (Apache configuration problem?)

am 04.09.2007 04:00:24 von Macca

As stated already, you can not access form vaiables directly anymore
and instead you should be using the $_GET/$_POST superglobal arrays,

So to access the variable set in your URL, which is a GET query string
you would use:

$dummy = $_GET['dummy'];

Or for your example:

if (isset($_GET['dummy'])){
echo "Set";
} else {
echo "Not Set";
}