View Full Version : Annoying % Error...

07-09-2007, 01:38 AM
I have the following line...

$results = mysql_query("SELECT * FROM `table` WHERE `FirstName` LIKE '%$firstName%' AND `LastName` LIKE '%$lastName%` AND `Email` LIKE '%$email%' AND `State`='$state' AND `mng`='$mng' AND `Member`='$status'") or die ('Error: '.mysql_error ());

But keep getting the following error...

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%' AND `State`='sa' AND `mng`='1' AND `Member`='A'' at line 1

07-09-2007, 01:47 AM
Sounds like you haven't escaped your SQL properly... don't forget to use mysql_real_escape_string() on everything you intend to send in a MySQL query.

If that doesn't help, try printing out the whole query, with inserted data.