Jump to content

[SOLVED] FULLTEXT search returns nothing


advancedfuture

Recommended Posts

Well i was working on a very basic search form and for some reason I can't it to return anything.

I even put the query into query browser to check if my syntax is correct (it is!) but still it returns nothing. I am trying to search the column 'resume' for specific keyword(s) which i know exist in the column but still nothing... =( Fulltext indexing is enabled.

 

Any idea's by looking at my code why this wouldn't be returning any results?

 

<?php

include 'dbconnect.php';

echo '<form name="form1" id="form1" method="post" action="">
<input type="text" name="search_text">
<input type="submit" name="search" value="Search">
</form>';

//EXECUTE IF THE SEARCH FORM IS ACTIVATED
if($_POST['search'])
{
$search_text = $_POST['search_text'];

$query = "SELECT *, MATCH (resume) AGAINST ('$search_text') AS score FROM profile WHERE MATCH (resume) AGAINST ('$search_text') ORDER BY score DESC";
$results = mysql_query($query);

while($row = mysql_fetch_array($results))
{
	echo $row['username']."<br />";
	echo $row['headline']."<br />";
}

}
?>

Link to comment
https://forums.phpfreaks.com/topic/85876-solved-fulltext-search-returns-nothing/
Share on other sites

<?php

include 'dbconnect.php';

echo '<form name="form1" id="form1" method="post" action="">
<input type="text" name="search_text">
<input type="submit" name="search" value="Search">
</form>';

//EXECUTE IF THE SEARCH FORM IS ACTIVATED
if($_POST['search'])
{
$search_text = $_POST['search_text'];

$query = "SELECT *, MATCH (resume) AGAINST ('$search_text') AS score FROM profile WHERE `resume` like '$search_text%' ORDER BY score DESC";
$results = mysql_query($query);

while($row = mysql_fetch_array($results))
{
	echo $row['username']."<br />";
	echo $row['headline']."<br />";
}

}
?>

 

I think thats how it works, i just don't know what fields your searching.

<?php

include 'dbconnect.php';

echo '<form name="form1" id="form1" method="post" action="">
<input type="text" name="search_text">
<input type="submit" name="search" value="Search">
</form>';

//EXECUTE IF THE SEARCH FORM IS ACTIVATED
if($_POST['search'])
{
$search_text = $_POST['search_text'];

$query = "SELECT *, MATCH (resume) AGAINST ('$search_text') AS score FROM profile WHERE `resume` like '$search_text%' ORDER BY score DESC";
$results = mysql_query($query);

while($row = mysql_fetch_array($results))
{
	echo $row['username']."<br />";
	echo $row['headline']."<br />";
}

}
?>

 

I think thats how it works, i just don't know what fields your searching.

 

This returned 1 result.... despite the fact my query should match multiple results...

for that matter of fact i tried something outrageous... i tried this query

 

SELECT *, MATCH(resume) AGAINST('blaasdasdasdasdasdasdasadsdasdasda') from profile

 

and it returned every row in table 'profile'... and i can tell you this much "blaasdasdasdasdasdasdasadsdasdasda" doesn't exist in any 'resume' column....

 

hmmm still stumped

So I figured out what was wrong...

 

Apparently NOTHING was wrong with my first query that I posted... but apparently MySQL has to have more than 3 rows in the database for the MATCH AGAINST to work properly....

 

Learning something new everyday!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.