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:[EMAIL PROTECTED]]
Sent: Friday, October 19, 2001 5:22 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
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:[EMAIL PROTECTED]
webmail: mailto:[EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to