lilman Posted December 9, 2006 Share Posted December 9, 2006 I want to search my db's columns title and author. Here is the code I've written:[code]$query = "SELECT * FROM bookcatalog WHERE title like \"%$title%\", author like \"%$author%\"";$runquery=mysql_query($query) or die(mysql_error());[/code]When I run it I get this 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 ' author like "%Isaac%"' at line 1It worked fine until I added this part of the code [code], author like \"%$author%\"[/code]Any help would be great! Link to comment https://forums.phpfreaks.com/topic/30062-search-db-with-multiple-search-strings/ Share on other sites More sharing options...
Psycho Posted December 9, 2006 Share Posted December 9, 2006 Replace the comma with either 'AND' or 'OR' (without the quotemarks) depending on what you want."SELECT * FROM bookcatalog WHERE title like \"%$title%\" AND author like \"%$author%\"""SELECT * FROM bookcatalog WHERE title like \"%$title%\" OR author like \"%$author%\"" Link to comment https://forums.phpfreaks.com/topic/30062-search-db-with-multiple-search-strings/#findComment-138203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.