Page 1 of 1

WHERE lower LIKE statement

Posted: Tue Jul 29, 2008 3:10 am
by deejay
Hi

Am puzzled as why this bit of code won't work for me.

Code: Select all

 
if (isset($_GET['wordsearch'])){
$word = strtolower($_GET['wordsearch']);
echo $word.'= $word <BR>';
$query .= " WHERE lower(lname) OR lower(fname)  LIKE'%$word%' ";
 
 
it works if use either

Code: Select all

$query .= " WHERE lower(lname)  LIKE'%$word%' ";
or

Code: Select all

$query .= " WHERE  lower(fname)  LIKE'%$word%' ";
but not when I add the OR statement it only gives me the result on what comes second in the statement. any ideas? :banghead:

Re: WHERE lower LIKE statement

Posted: Tue Jul 29, 2008 3:32 am
by jaoudestudios
Your line 4 is wrong!

In line 5 you need a space after LIKE

You are using OR incorrectly.

It should be...

Code: Select all

$query .= " WHERE lower(lname) LIKE '%".$word."%' OR lower(fname) LIKE '%".$word."%'";

Re: WHERE lower LIKE statement

Posted: Tue Jul 29, 2008 3:40 am
by abhikerl
For queries in sql, I suggest you to used sqlyog. It's a software that helps you to make queries, then you can copy, paste it in your code.

Re: WHERE lower LIKE statement

Posted: Tue Jul 29, 2008 3:58 am
by deejay
cheers all :)