Re: problems in WHERE statment
| From: | Jared Farrish | Date: | Wed, 23 May 2007 17:28:11 +0000 |
| Subject: | Re: problems in WHERE statment | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-255448@lists.php.net to get a copy of this message | ||
Change the single quote to a double quote:
<code>
$query = "SELECT * FROM
job listing WHERE open >= '$today' LIMIT 0 , 30
";
</code>
This tells the PHP string parser to replace all declared, in-scope variables
that are detected in a string with the value of the variable (as a
toString() method, so a reference would not pass in the actual data, it
would print something like "Resource id #3").
When you use single-quotes, you are telling the parser to keep it's hands
off the string, and use "as-is".
Example:
<code>
var $a = 'test';
var $b = 'test2';
var $c = '$a$b';
var $d = "$a$b";
var $e = $a.$b;
</code>
$e is equivalent to $d, where c would print literally $a$b, since you told
the parser using the single quotes to leave the string alone.
Likewise, var $f = $a."-$b$c-".'$e'; would print test-test2$a$b-$e;
--
Jared Farrish
Intermediate Web Developer
Denton, Tx
Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$