watts Posted November 29, 2006 Share Posted November 29, 2006 I've just uploaded my site from my local server, where everything worked fine, to a new remote server and my full-text search is no longer working properly. It's not using boolean mode and it's only returning results for the first word in the search string so if the search string is "abstract vertical" it returns the same number of results as "abstract"Here's code for the search:[code] function searchForm(){ //reusable form //variable setup for the form$searchwords = (isset($GET['newWords']) ? htmlspecialchars(stripslashes($_REQUEST['words'])) :'');echo "<div id='searchField'>\n";echo "<form method='get' action='".$_SERVER['PHP_SELF']."'>\n";echo "<input type='hidden' name='cmd' value='search' />\n";echo "Search for: <input type='text' name='words' value='".$searchwords."' /> \n";echo "<input type='submit' value='SEARCH' />\n";echo "</form>\n";echo "<p>Enter your keywords separated by spaces. The search will only return exact matches (no partial word matches) for all words present and display the thumbnails.</p>\n";echo "</div>\n"; //END DIV FOR SEARCHFIELD}//ADD BOOLEAN OPERATORS//CHECK IF IT'S FIRST SEARCH PAGE OR IF BOOLEAN OPERATORS HAVE ALREADY BEEN ADDEDif (isset($_GET['words'])){ $words=$_GET['words']; $newWords = str_replace(' ','+',$words); $newWords = str_replace($newWords,'+'.$newWords,$newWords);} elseif (isset($_GET['newWords'])) { $newWords = $_GET['newWords'];}// CREATE THE NAVIGATION SWITCH$cmd = (isset($_GET['cmd']) ? $_GET['cmd'] : '');switch($cmd){ default; echo "<h2>Search Images</h2>"; searchForm(); break; case "search"; searchForm();//OPEN DIV FOR DISPLAYED RESULTS echo "<div id=searchResults>\n"; $searchstring = mysql_escape_string($newWords);//SET LIMIT AND DETERMINE NUMBER OF IMAGES$limit = 20;$perRow = 4; $limitValue=($page*$limit)-($limit); $table_row=1; $sql = "SELECT imgID, imgURL, imgThbURL, imgLabel, imgCaption, imgTitle, imgTitleMeta, imgDescription, MATCH(imgTitle, imgCaption, imgDescription) AGAINST ('$searchstring' IN BOOLEAN MODE) AS score FROM images WHERE MATCH(imgTitle, imgCaption, imgDescription) AGAINST ('$searchstring' IN BOOLEAN MODE) ORDER BY score DESC LIMIT $limitValue, $limit"; $result = mysql_query($sql) or die (mysql_error('Could not connect to database')); $countImg = mysql_num_rows($result);[/code]This works fine on my local server which is running mysql 5 but it doesn't work properly on the remote server which is running mysql 4.1.10. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 3, 2006 Share Posted December 3, 2006 Boolean mode was added in some minor version, don't remember which, but it was late. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.