...

View Full Version : sql string comparison problem



allanb7
11-08-2010, 12:44 PM
Hello everybody.

I have a little problem with a sql string comparison.

I tried to use the following code to compare two different rows by a variable to
get a result..

The code works fine if the variable is a number like: 12345
But if I use letters and numbers like: AZ1234 It doesn't work.

Code:


$database->setQuery( 'SELECT task_id FROM #_projects WHERE title = '.$jid );


What am I missing..??

Hope you can help me..

Best regards
Allan.

poyzn
11-08-2010, 01:02 PM
try


$database->setQuery("SELECT task_id FROM #_projects WHERE title = '".$jid."'");

allanb7
11-08-2010, 01:10 PM
Thank you so much poyzn..

That did the trick!!!

Best regards
Allan

Keleth
11-08-2010, 04:07 PM
More specifically, always remember you have to quote strings, just like in any other language.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum