Page 1 of 1

Using Fulltext queries [SOLVED]

Posted: Thu Oct 04, 2007 10:49 am
by aceconcepts
Hi,

I'm using the following code to return any records found matching a search input via the variables $varText.

Code: Select all

include"connection_to_db.php";

if(isset($_POST['submit']))
{
	$varText=$_POST['text'];
	
	$query=mysql_query("SELECT * FROM tblFullText
						WHERE MATCH (strText) AGAINST ('$varText')");
	if(mysql_num_rows($query)==0)
	{
		echo'Nothing found, sorry!';
	}
		else
	{
		while($row=mysql_fetch_array($query))
		{
			echo $row['strText'];
		}
	}
}
My problem is, it keeps displaying my error "Nothing found, sorry!". I enter in search words that i know exist in the table and still the error message persists.

P.s. the table column 'strText' is defined as "Fulltext" in the database.

Any ideas?

Posted: Thu Oct 04, 2007 10:52 am
by John Cartwright

Code: Select all

$query=mysql_query("SELECT * FROM tblFullText WHERE MATCH (strText) AGAINST ('$varText')") or die(mysql_error());
Try adding the errror reporting as shown above to see if the query is failing.

Posted: Thu Oct 04, 2007 10:56 am
by aceconcepts
Query is not failing. I added the error reporting and no error shows.

Posted: Thu Oct 04, 2007 11:06 am
by John Cartwright

Code: Select all

echo "SELECT * FROM tblFullText WHERE MATCH (strText) AGAINST ('$varText')"
What does this return, and can you provide a sample export of the data you are attempting to fetch?

Posted: Thu Oct 04, 2007 11:07 am
by feyd
If the search matches 50% or more of the records, it is excluded as being too frequent.

Posted: Thu Oct 04, 2007 11:13 am
by aceconcepts
i re-created the table and it works perfectly now.

How odd, maybe there was a database glitch.

Anyway, thanks for you help. :D