PHP - Matching search terms mysql_query

2019-09-08 06:50发布

问题:

im having issue with a php script that retrieves values from a database and see's which ones match an input term. I either get the resourceID #4 error or no response.

Im basically trying to retrieve similar entries and of those similar entries show the name and date of their submission

$input = mysql_real_escape_string($_POST["interest"]);
$query1 = "SELECT name,interest_desc,date, MATCH(interest_desc) AGAINST('$input') AS score
 FROM interests
 WHERE MATCH(interest_desc) AGAINST('$input')
 ORDER BY score DESC
 LIMIT 10
 ";

 $result = mysql_query($query1) or die(mysql_error());
 while ($row = mysql_fetch_assoc($result)) {
 echo $row['name'];
 echo $row['interest_desc'];
echo $row['date'];
 }

I must be going wrong with my syntax, any pointers? im pulling my hair out over this!

回答1:

Have you indexed the field as full text and is your table myisam. See this for more detail.