Page 1 of 1

MySQL Syntax Error

Posted: Mon May 28, 2012 6:39 am
by nnjgmatt
The query im making is:

Code: Select all

SELECT COUNT(*) as num FROM items_available WHERE `title` LIKE '%%' AND category=1
And it looks like this in the code:

Code: Select all

if($category=="All Categories"){
		$query = "SELECT COUNT(*) as num FROM items_available WHERE $where";
	}else{
		$query = "SELECT COUNT(*) as num FROM items_available WHERE `title` LIKE '%$keyword%' AND category=$category ";
	}
$results = mysql_fetch_array(mysql_query($query));
And Im getting this error:

Code: Select all

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 category='1'' at line 1
I have been trying and testing for a while now and I just cant figure out. Please help me out