[UPHPU] Query Help

John David Anderson uphpu at johndavidanderson.net
Thu Apr 5 14:10:07 MDT 2007


On Apr 5, 2007, at 2:03 PM, Webot Graphics wrote:

> I am trying to match a search form with items in a mysql database  
> this is the code I have, but it doesn't work.
>
> $searchstring = ($_GET['search']);
> $sql = "SELECT * MATCH(Customer_Product_Name) AGAINST  
> ('$searchstring') AS score FROM Customer_Product_Names WHERE MATCH 
> (Customer_Product_Name) AGAINST ('$searchstring') ORDER BY score  
> DESC";
> $result = @mysql_query($sql);
> if (!$result) {
> 	 exit('<p>Error performing query: ' . mysql_error() . '</p>');
> }
>
> this is the error I get when searching for "formula"
> Error performing query: 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 'MATCH(Customer_Product_Name) AGAINST  
> ('formula') AS score FROM Customer_Product_' at line 1

You need to tell MySQL which table you plan to use.

SELECT * FROM `TableName` WHERE MATCH....

http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

-- John


More information about the UPHPU mailing list