Connecting Tech Pros Worldwide Help | Site Map

$_GET['var'] works, but $var doesn't

Sjaakie Helderhorst
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi,
I recently installed the latest Fedora Core 2 but have some troubles of
which I'm not sure are PHP or Apache 2 related... apologies if this is the
wrong group.

"http://www.domain.ltd/index.php?var=123&"
Somehow, $var returns an empty value, while $_GET['var'] returns '123'. Need
I change a parameter in php.ini or somewhere else?

Thanks in advance for any help!


Marian Heddesheimer
Guest
 
Posts: n/a
#2: Jul 17 '05

re: $_GET['var'] works, but $var doesn't


On Wed, 9 Jun 2004 10:57:18 +0200, "Sjaakie Helderhorst"
<prefer.notto@tell.you> wrote:
[color=blue]
>Somehow, $var returns an empty value, while $_GET['var'] returns '123'. Need[/color]

seems you should turn on your register_globals

change the line
register_globals=off

to
register_globals=on

in your php.ini file

or better yet, always user $_GET and $_POST to access your form
variables.

Regards

Marian

--
http://www.heddesheimer.de mailto:marian@heddesheimer.de
http://www.rent-a-tutor.com Software on the Web
Chris Hope
Guest
 
Posts: n/a
#3: Jul 17 '05

re: $_GET['var'] works, but $var doesn't


Marian Heddesheimer wrote:
[color=blue]
> or better yet, always user $_GET and $_POST to access your form
> variables.[/color]

That's good advice. The good thing about using $_GET['foo'] and
$_POST['foo'] etc rather than enabling register globals and using $foo, is
that it ensures greater portability of your scripts. You may well be able
to register globals on your development box but this may not be the case
with your hosting provider.

--
Chris Hope
The Electric Toolbox - http://www.electrictoolbox.com/
Sjaakie Helderhorst
Guest
 
Posts: n/a
#4: Jul 17 '05

re: $_GET['var'] works, but $var doesn't


"Chris Hope" <chris@electrictoolbox.com> schreef in bericht
news:1086777890_24934@news.athenanews.com...[color=blue]
> Marian Heddesheimer wrote:
>[color=green]
> > or better yet, always user $_GET and $_POST to access your form
> > variables.[/color]
>
> That's good advice. The good thing about using $_GET['foo'] and
> $_POST['foo'] etc rather than enabling register globals and using $foo, is
> that it ensures greater portability of your scripts. You may well be able
> to register globals on your development box but this may not be the case
> with your hosting provider.
>
> --
> Chris Hope
> The Electric Toolbox - http://www.electrictoolbox.com/[/color]

Thank you both for your help!
I usually use $_GET and $_POST, but this is a site I 'adopted', so I
encounter some difficulties.
Thanks again!


FLEB
Guest
 
Posts: n/a
#5: Jul 17 '05

re: $_GET['var'] works, but $var doesn't


Regarding this well-known quote, often attributed to Sjaakie Helderhorst's
famous "Wed, 9 Jun 2004 13:35:46 +0200" speech:
[color=blue]
> "Chris Hope" <chris@electrictoolbox.com> schreef in bericht
> news:1086777890_24934@news.athenanews.com...[color=green]
>> Marian Heddesheimer wrote:
>>[color=darkred]
>>> or better yet, always user $_GET and $_POST to access your form
>>> variables.[/color]
>>
>> That's good advice. The good thing about using $_GET['foo'] and
>> $_POST['foo'] etc rather than enabling register globals and using $foo, is
>> that it ensures greater portability of your scripts. You may well be able
>> to register globals on your development box but this may not be the case
>> with your hosting provider.
>>
>> --
>> Chris Hope
>> The Electric Toolbox - http://www.electrictoolbox.com/[/color]
>
> Thank you both for your help!
> I usually use $_GET and $_POST, but this is a site I 'adopted', so I
> encounter some difficulties.
> Thanks again![/color]

For now, you can add code like:

<?php
$INPUTS = array_merge($_GET, $_POST, $_COOKIE);
// Eliminate any of the $_ vars you don't need.

foreach ($_INPUTS as $currentInput => $thisInput) {
${$currentInput} = $thisInput;
}
?>

(UNTESTED! TRY IT FIRST!)

It's a band-aid procedure, and a bit insecure, but it should tide you over
for now.

--
-- Rudy Fleminger
-- sp@mmers.and.evil.ones.will.bow-down-to.us
(put "Hey!" in the Subject line for priority processing!)
-- http://www.pixelsaredead.com
Closed Thread