1

EDIT: please note this query does not work with four+ letters either

I've been attempting to use the below query unsuccessfully. The problem is not that zero results return, but that the query itself seems to be broken as when I use var_dump to assess the query I get an error. This same code structure worked for me on another script so i'm not sure what i'm missing. I can't remember if there's a setting in php that I need to activate or similar? I am running on localhost using Xampp...

$sql = "SELECT * FROM cars WHERE MATCH (car_content) AGAINST ('test')" ;
$query = mysql_query($sql);
var_dump($query);
$num = mysql_num_rows($query);

Output:

bool(false) 
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in

Any ideas what could be wrong? I have simplified the query to the above to try and get something working, but the actual query I want to run is for a site search function:

$sql = "SELECT * FROM cars WHERE MATCH (car_content, car_reference, car_tags) AGAINST ('$query')" ;

Thanks.

tensai288
  • 71
  • 1
  • 8
  • Use `echo mysql_error()` to see the error message when `mysql_query()` returns `false`. – Barmar Feb 28 '15 at 22:23
  • The error is: Can't find FULLTEXT index matching the column list – tensai288 Feb 28 '15 at 22:27
  • You can't use `MATCH` if you haven't created a full-text index on the column. Read the documentation on full-text searching. – Barmar Feb 28 '15 at 22:28
  • I've now added fulltext to all the columns - but the same error remains. Any ideas why this might be? – tensai288 Feb 28 '15 at 22:42
  • I've finally got it working on SOME queries. After pressing the "fulltext" index button in phpmyadmin several times. However, the query doesn't seem to work with multiple columns, at least some of the time... very strange – tensai288 Feb 28 '15 at 23:24
  • I have made more progress through using: IN BOOLEAN MODE. – tensai288 Mar 01 '15 at 09:39

0 Answers0