Using Fulltext queries [SOLVED]

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Using Fulltext queries [SOLVED]

Post 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?
Last edited by aceconcepts on Thu Oct 04, 2007 11:31 am, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post by aceconcepts »

Query is not failing. I added the error reporting and no error shows.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If the search matches 50% or more of the records, it is excluded as being too frequent.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post 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
Post Reply