RE: [PHP-DB] variable operators in queries
| From: | Rick Emery | Date: | Mon, 22 Oct 2001 13:20:04 +0000 |
| Subject: | RE: [PHP-DB] variable operators in queries | ||
| Groups: | php.db php.general | ||
| Request: | Send a blank email to php-db+get-13600@lists.php.net to get a copy of this message | ||
Is the the EXACT code you used? If it is, I can see why it failed. You're
trying to assign the text to "sql" not "$sql".
sql="SELECT * FROM poeple WHERE age $Date_operator 20";
If, in fact, you are assigning to $sql, then print out $sql to ensure it
contains what you expect it to contain.
-----Original Message-----
From: Sander Peters [mailto:S.Peters@Visionnet.nl]
Sent: Friday, October 19, 2001 5:22 PM
To: php-db@lists.php.net; php-general@lists.php.net
Subject: [PHP-DB] variable operators in queries
Hello,
Is it possible to put variable operators in queries?
I tried this (the real variable comes from a form)
$Date_Operator =(">=");
sql="SELECT * FROM poeple WHERE age $Date_operator 20";
$result_id = mysql_query($sql);
It doesn't work like this. I also tried:
sql="SELECT * FROM poeple WHERE age \"$Date_operator\" 20"
$result_id = mysql_query($sql);
it didn't work either.
Or should I use a have to make a IF-Then construction?
If $Date_Operator == (">=")
then
{
sql="SELECT * FROM poeple WHERE age >= 20"
}
etc...
Can anybody help me with this?
Thanks in advance!
--
Met vriendelijke groet / With Greetings,
Sander Peters
site: http://www.visionnet.nl/
email: mailto:s.peters@visionnet.nl
webmail: mailto:sanderpeters@yahoo.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net