【问题标题】:PHP - Matching search terms mysql_queryPHP - 匹配搜索词 mysql_query
【发布时间】:2011-12-13 23:56:09
【问题描述】:

我遇到了一个从数据库中检索值并查看与输入项匹配的 php 脚本的问题。我要么得到 resourceID #4 错误,要么没有响应。

我基本上是在尝试检索类似的条目,并且在那些类似的条目中显示他们提交的名称和日期

$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'];
 }

我的语法一定有问题,有什么建议吗?我把头发拉出来了!

【问题讨论】:

  • 您的 SQL 似乎有问题。你是否对你的数据库运行过查询(比如在 phpMyAdmin 中,或者其他什么)? mysql_error() 说什么,如果有的话?
  • SQL 实际上是正确。您的问题几乎可以肯定地在这个现有的 SO 帖子中得到解决:MySQL FULLTEXT Not Working
  • 需要处于布尔模式。现在可以使用了,谢谢

标签: php mysql search match


【解决方案1】:

您是否将该字段索引为全文并且是您的表 myisam。详情请参阅this

【讨论】:

    猜你喜欢
    • 2018-06-07
    • 2014-08-17
    • 1970-01-01
    • 2011-03-13
    • 1970-01-01
    • 2021-07-11
    • 2015-08-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多