Connecting Tech Pros Worldwide Help | Site Map

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

  #1  
Old July 17th, 2005, 06:43 AM
Sjaakie Helderhorst
Guest
 
Posts: n/a
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!


  #2  
Old July 17th, 2005, 06:43 AM
Marian Heddesheimer
Guest
 
Posts: n/a

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
  #3  
Old July 17th, 2005, 06:43 AM
Chris Hope
Guest
 
Posts: n/a

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/
  #4  
Old July 17th, 2005, 06:43 AM
Sjaakie Helderhorst
Guest
 
Posts: n/a

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!


  #5  
Old July 17th, 2005, 06:44 AM
FLEB
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple ajax works in chrome and FF but not IE oneadvent answers 6 September 28th, 2009 11:23 AM
Switch isset and $_get wouter answers 9 October 23rd, 2006 01:15 AM
anchor and get var in url... ToMeK answers 6 October 7th, 2005 06:55 PM
Is there a setting to allow $var = "" when POST and GET vars are strict? Keiron Waites answers 1 July 17th, 2005 01:18 AM