Forum Moderators: coopster

Message Too Old, No Replies

The LIKE Operator

         

Komodo_Tale

3:18 am on May 10, 2006 (gmt 0)

10+ Year Member



Why does this not work? Thank you.

if ($kw LIKE "%baby%"){$XXX=TRUE;}

grandpa

4:33 am on May 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



LIKE, as you are using it in PHP isn't a valid operator [us2.php.net].

What would be valid would be to craft a query..

$sql = "SELECT * from table WHERE $kw LIKE '%baby%'";

Then you can continue with $XXX=TRUE if the statement returns true.

barns101

11:34 am on May 10, 2006 (gmt 0)

10+ Year Member



Or if you are just using PHP, try the stristr() [uk2.php.net] function instead.