Connecting Tech Pros Worldwide Help | Site Map

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

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 05:43 AM
Sjaakie Helderhorst
Guest
 
Posts: n/a
Default $_GET['var'] works, but $var doesn't

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, 05:43 AM
Marian Heddesheimer
Guest
 
Posts: n/a
Default 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, 05:43 AM
Chris Hope
Guest
 
Posts: n/a
Default 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, 05:43 AM
Sjaakie Helderhorst
Guest
 
Posts: n/a
Default 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, 05:44 AM
FLEB
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.