Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

MySQL Syntax Error

Codes here !

Moderators: macek, egami, gesf

MySQL Syntax Error

Postby nnjgmatt » Mon May 28, 2012 6:39 am

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
nnjgmatt
New php-forum User
New php-forum User
 
Posts: 6
Joined: Mon Apr 23, 2012 2:33 pm

Return to mySQL & php coding

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.