RE: [PHP] Newbie question about variable scope in Apache 2.0 & PH P
| From: | Ford, Mike [LSS] | Date: | Thu, 08 May 2003 09:34:57 +0000 |
| Subject: | RE: [PHP] Newbie question about variable scope in Apache 2.0 & PH P | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-146810@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Wendell Brown [mailto:wbrown@arkie.net]
> Sent: 07 May 2003 18:11
>
> On Wed, 7 May 2003 11:31:25 -0400, Steve Henderson wrote:
>
> >I am having trouble with variables remaining in scope
> between forms and
> >scripts. I keep getting errors saying $val1 is not defined
> etc. This
>
> I suspect that the problem is that you have "register_globals" turned
> off (it's a safety default in newer versions of PHP). There are a few
> possible solutions:
>
> 1) Turn on register_globals on... this can be set in the php.ini or
> (under Apache) in the .htaccess file.
>
> 2) Use the "long name" for the variable. Instead of:
>
> echo "$val2";
Uh, oh! Attack of the superfluous quotes!
echo $val2;
>
> try this:
>
> echo "$_POST(\"val2\")";
echo $_POST['val2'];
>
> 3) Or extract the $_POST array....
>
> extract( $_POST );
> echo "$val2";
echo $val2;
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211