Re: Re: Difference between $_POST[foo] and $_POST['foo']?
| From: | Chris Hayes | Date: | Tue, 17 Jun 2003 14:47:48 +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-151840@lists.php.net to get a copy of this message | ||
At 16:37 17-6-03, you 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]May i rephrase that to: "Use quotes whenever possible, with one exception: within double quotes." Reason: your rule of thumb fails with: $val=$_POST['val']; Plus: when using CONSTANTs as keys, do not try to access them within quoted strings.
so it your example it would be: $sql = "select * from db where apple = '$_POST[foo]'";