Page 1 of 1

FULLTEXT search problems .... [FIXED]

Posted: Sat Sep 30, 2006 4:31 am
by pgolovko
[EDIT] By my own dumb self I've been searching my "test" database with phpMyAdmin, while the following PHP code was applied to the real database. The following is a correct way to FULLTEXT search the database, no further problems came up. Thank you all!


The following query:

Code: Select all

SELECT *, MATCH(url,title,description) AGAINST ('free design and templates') as Relevance FROM links WHERE MATCH (url,title,description) AGAINST('free design and templates' IN BOOLEAN MODE) ORDER BY Relevance DESC
....gives me 3 results from within phpMyAdmin so it works fine, but the same search query from within my PHP script gives me the following error:
Can't find FULLTEXT index matching the column list
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/pgolovko/public_html/adp/search1.php on line 24
PHP code:

Code: Select all

$searchwords = addslashes(htmlspecialchars($_POST['swords']));
	if (strlen($searchwords) < 3){
		echo "The word you have inputted is too short, please enter another one.";
		}
	else{
		$sql = "SELECT *, MATCH(url,title,description) AGAINST ('$searchwords') as Relevance FROM links WHERE MATCH (url,title,description) AGAINST('$searchwords' IN BOOLEAN MODE) ORDER BY Relevance DESC";
		$result = mysql_query($sql);
		echo mysql_error();
		if (mysql_num_rows($result) <> ''){
			while ($row = mysql_fetch_array($result)) {
				$url = $row['url'];
				$title = $row['title'];
				$description = " - ".$row['description'];
				print "<li><a href=\"$url\">$title</a>$description";
				}
			}

		}
What am I doing wrong here?