Re: Re: Difference between $_POST[foo] and $_POST['foo']?

From: Date: Wed, 18 Jun 2003 20:14:26 +0000
Subject: Re: Re: Difference between $_POST[foo] and $_POST['foo']?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-152055@lists.php.net to get a copy of this message
On 17 Jun 2003 09:37:12 -0500, Tom Woody <woody@nfri.com> wrote:
On Tue, 2003-06-17 at 09:09, nabil wrote:
A side question along with this ,,, how can I include $_POST['foo'] in the : $sql ="select * from db where apple = '$_POST['foo']' "; without getting an error ?? should I append it as $var= $_POST['foo']; before???
The rule of thumb I follow with these and other Associative Arrays is: when setting the variable its $_POST['foo'] when accessing the variable its $_POST[foo] so it your example it would be: $sql = "select * from db where apple = '$_POST[foo]'";
print $_POST[foo]; // generates either E_WARNING or E_NOTICE (forget which) print $_POST['foo']; // does not generate a warning print "$_POST[foo]"; // does not generate a warning print "$_POST['foo']"; // generates a warning -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

« previous php.general (#152055) next »