MySQL Forums
Forum List  »  PHP

Need Help ! problem in exact phrase mysql full text search function.
Posted by: Annabel Teng
Date: January 09, 2008 02:11PM

hi, i am new to this. Please help me. I am doing an advance search (exact phrase or all of the words) search.

From what i read in the reference manual 10.8 full text search function. They said
that to find rows that contain the exact phrase
i have to use this
'"some words"'
Note that the “"” characters that enclose the phrase are operator characters that delimit the phrase. They are not the quotes that enclose the search string itself.

I understand this concept. This can be used if you directly use the mysql tool. But i am using from a web application instead- a search form.
I use string- $all to represent all the words type in the form.
For example i want to search for cartoon network
Then my $all would be cartoon network.

This is my sql statement in php
$sql = "SELECT * FROM image WHERE MATCH (ImageName, ImageTittle, ImageTag, ImageCatgy)
AGAINST ('"$all "' IN BOOLEAN MODE)";

if(!$result) {
echo MySQL_error()."<br>$sql<br>";
}
echo "<b>Search Complete</b><br>";

if(MySQL_num_rows($result) > 0) {
echo "<table>";
echo "<tr><td>Image</td><td></td><td>ImageName </td><td></td><td>ImageTittle </td><td></td><td>ImageCatgy </td></tr>";

while($result2 = MySQL_fetch_array($result)) {


$fName = $result2['ImageName'];

$val = round($result2['clickcount'], 3);
$val = $val*100;
echo "<tr><td><img src=".$thumbdir."thumb_".$fName."><br><td></td></td>";
echo "<td>{$result2['ImageName']}<td></td></td>";
echo "<td>{$result2['ImageTittle']}<td></td></td>";
echo "<td>{$result2['ImageCatgy']}<td></td></td></tr>";
}
echo "</table>";

}
else {
echo "No Results were found in this category.<br>";
}
echo "<br>";


Yet when i do accordingly ('"some words"') i have this error

Parse error: parse error, unexpected T_VARIABLE in C:\Program Files\xampp\htdocs\cel\do_search4.php on line 54

Line 54 is this line- AGAINST ('"$all "' IN BOOLEAN MODE)";



Edited 1 time(s). Last edit at 01/10/2008 10:50PM by Annabel Teng .

Options: ReplyQuote


Subject
Written By
Posted
Need Help ! problem in exact phrase mysql full text search function.
January 09, 2008 02:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.