PHP/MySQL search engine script
Here is a quick tutorial/script to show you how to create PHP/MySQL search engine with search keywords displayed in bold.
List of some PHP functions used:
- trim() - Strip whitespace (or other characters) from the beginning and end of a string
- explode() - Split a string by string
- array_unique() - Removes duplicate values from an array
- preg_replace() - Perform a regular expression search and replace
Save the file as search.php and upload it to your server.
See the commented sections for details.
<?php
$hostname_logon = "localhost" ;
$database_logon = "databaseName" ;
$username_logon = "databaseUser" ;
$password_logon = "databasePass" ;
//open database connection
$connections = mysql_connect($hostname_logon, $username_logon, $password_logon) or die ( "Unabale to connect to the database" );
//select database
mysql_select_db($database_logon) or die ( "Unable to select database!" );
//specify how many results to display per page
$limit = 10;
//get the search variable from URL
$var = mysql_real_escape_string(@$_REQUEST['q']);
//get pagination
$s = mysql_real_escape_string($_REQUEST['s']);
//set keyword character limit
if(strlen($var) < 3){
$resultmsg = "<p>Search Error</p><p>Keywords with less then three characters are omitted...</p>" ;
}
//trim whitespace from the stored variable
$trimmed = trim($var);
$trimmed1 = trim($var);
//separate key-phrases into keywords
$trimmed_array = explode(" ",$trimmed);
$trimmed_array1 = explode(" ",$trimmed1);
// check for an empty string and display a message.
if ($trimmed == "") {
$resultmsg = "<p>Search Error</p><p>Please enter a search...</p>" ;
}
// check for a search parameter
if (!isset($var)){
$resultmsg = "<p>Search Error</p><p>We don't seem to have a search parameter! </p>" ;
}
// Build SQL Query for each keyword entered
foreach ($trimmed_array as $trimm){
// EDIT HERE and specify your table and field names for the SQL query
// MySQL "MATCH" is used for full-text searching. Please visit mysql for details.
$query = "SELECT * , MATCH (field1, field2) AGAINST ('".$trimm."') AS score FROM table_name WHERE MATCH (field1, field2) AGAINST ('+".$trimm."') ORDER BY score DESC";
// Execute the query to get number of rows that contain search kewords
$numresults=mysql_query ($query);
$row_num_links_main =mysql_num_rows ($numresults);
//If MATCH query doesn't return any results due to how it works do a search using LIKE
if($row_num_links_main < 1){
$query = "SELECT * FROM table_name WHERE field1 LIKE '%$trimm%' OR field2 LIKE '%$trimm%' ORDER BY field3 DESC";
$numresults=mysql_query ($query);
$row_num_links_main1 =mysql_num_rows ($numresults);
}
// next determine if 's' has been passed to script, if not use 0.
// 's' is a variable that gets set as we navigate the search result pages.
if (empty($s)) {
$s=0;
}
// now let's get results.
$query .= " LIMIT $s,$limit" ;
$numresults = mysql_query ($query) or die ( "Couldn't execute query" );
$row= mysql_fetch_array ($numresults);
//store record id of every item that contains the keyword in the array we need to do this to avoid display of duplicate search result.
do{
$adid_array[] = $row[ 'field_id' ];
}while( $row= mysql_fetch_array($numresults));
} //end foreach
//Display a message if no results found
if($row_num_links_main == 0 && $row_num_links_main1 == 0){
$resultmsg = "<p>Search results for: ". $trimmed."</p><p>Sorry, your search returned zero results</p>" ;
}
//delete duplicate record id's from the array. To do this we will use array_unique function
$tmparr = array_unique($adid_array);
$i=0;
foreach ($tmparr as $v) {
$newarr[$i] = $v;
$i++;
}
//total result
$row_num_links_main = $row_num_links_main + $row_num_links_main1;
// now you can display the results returned. But first we will display the search form on the top of the page
echo '<form action="search.php" method="get">
<div>
<input name="q" type="text" value="'.$q.'">
<input name="search" type="submit" value="Search">
</div>
</form>';
// display an error or, what the person searched
if( isset ($resultmsg)){
echo $resultmsg;
}else{
echo "<p>Search results for: <strong>" . $var."</strong></p>";
foreach($newarr as $value){
// EDIT HERE and specify your table and field unique ID for the SQL query
$query_value = "SELECT * FROM newsight_articles WHERE field_id = '".$value."'";
$num_value=mysql_query ($query_value);
$row_linkcat= mysql_fetch_array ($num_value);
$row_num_links= mysql_num_rows ($num_value);
//create summary of the long text. For example if the field2 is your full text grab only first 130 characters of it for the result
$introcontent = strip_tags($row_linkcat[ 'field2']);
$introcontent = substr($introcontent, 0, 130)."...";
//now let's make the keywods bold. To do that we will use preg_replace function.
//Replace field
$title = preg_replace ( "'($var)'si" , "<strong>\\1</strong>" , $row_linkcat[ 'field1' ] );
$desc = preg_replace ( "'($var)'si" , "<strong>\\1</strong>" , $introcontent);
$link = preg_replace ( "'($var)'si" , "<strong>\\1</strong>" , $row_linkcat[ 'field3' ] );
foreach($trimmed_array as $trimm){
if($trimm != 'b' ){
$title = preg_replace( "'($trimm)'si" , "<strong>\\1</strong>" , $title);
$desc = preg_replace( "'($trimm)'si" , "<strong>\\1</strong>" , $desc);
$link = preg_replace( "'($trimm)'si" , "<strong>\\1</strong>" , $link);
}//end highlight
}//end foreach $trimmed_array
//format and display search results
echo '<div class="search-result">';
echo '<div class="search-title">'.$title.'</div>';
echo '<div class="search-text">';
echo $desc;
echo '</div>';
echo '<div class="search-link">';
echo $link;
echo '</div>';
echo '</div>';
} //end foreach $newarr
if($row_num_links_main > $limit){
// next we need to do the links to other search result pages
if ($s >=1) { // do not display previous link if 's' is '0'
$prevs=($s-$limit);
echo '<div class="search_previous"><a href="'.$PHP_SELF.'?s='.$prevs.'&q='.$var.'">Previous</a>
</div>';
}
// check to see if last page
$slimit =$s+$limit;
if (!($slimit >= $row_num_links_main) && $row_num_links_main!=1) {
// not last page so display next link
$n=$s+$limit;
echo '<div class="search_next"><a href="'.$PHP_SELF.'?s='.$n.'&q='.$var.'">Next</a>
</div>';
}
}//end if $row_num_links_main > $limit
}//end if search result
?>
Here are some helpfull resources:
Download
Do you like this script? Download updated version.

Jacob Schmid
Thank you for the clear explanation and nice clean website. Easy to understand.
eplicanic
Thanks!
paulo
Hi Dear,
how are you doing? I have been looking for php search bar for long, but all i have gotten is php script without database table code. Could you please give me this code? thank you so much….
Paulo
rajesh
erros are :(
Notice: Undefined index: q in C:\wamp\www\my_ipl_mania\search.php on line 2
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\my_ipl_mania\search.php on line 59
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\my_ipl_mania\search.php on line 65
i need a code with serach box:(
very urgent:(
Aritra Das
Thank. I was looking for a script to generate keywords from descriptions. your script is easy to understand and gave me some idea about what i was looking for. :)
eplicanic
Thanks Aritra! Glad I could help.
Sagar
I am wondering if I could use multiple search criteria such as a list, text field, drop down, and ranges to get the results?
Btw, this is amazing. I am going to try it out.
eplicanic
Yes you could! But as you can imagine it would require some rewriting.
Sagar
I have sent you an email. Please let me know if you got it or not, and if you did, I’d really appreciate your response asap.
Thanks.
Sagar
Hello,
Would you be interested in creating a search engine with multiple fields? Could you kindly quote me your price.
Thanks,
Sagar.
francisco
Thanks a lot mate. Very usefull
OopEducation
Nice Post …Helped alot
Izzuddin
Thank’s really appreciate that….
Tejas Jadhav
Very nice post! I was searching over for almost 4 hrs and then I found this useful post, really helped me
M
you FOOL!!!…its very easy!!!
sachi
I got a error that is as follows
“Undefined index: s in C:\wamp\www\GSM\S\search.php on line 19 ‘
How could I select Obtain number for pagination. ?
Jefkine
try adding an @ before the $_REQUEST['s']
sachi
Another one error -
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\GSM\S\search.php on line 49 .
I changed table names ,columns but still same error.
Jefkine
you could also add a pregreplace to remove % or _ since in the above snippet % or _ returns everything in the database
the pregreplace could be something like: $var = preg_replace(“/[^a-zA-Z0-9\s]/”, “”, $var);
john
Hi guys,
I keep getting an error message saying “Couldn’t execute query”.
Please advise.
eplicanic
Hi John,
On line 65 replace: or die ( “Couldn’t execute query” ); with or die (“Error in query: $query. ” . mysql_error()); so you can troubleshoot your query.
Or you can download updated file which should be much easier to modify and use.
Izzuddin
i also have the same error…
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in ……
how to solve this?
eplicanic
Double check your queries.
john
i’ve decided not to use this and developed my own solution.
eplicanic
Sweet! Sometimes that’s the best way to go about it. Thanks for trying it out though!
Robin
Hi.
I got duplicate search result.
Code:
// now let’s get results.
$query .= ” LIMIT $s,$limit” ;
$numresults = mysql_query ($query) or die ( “Couldn’t execute query” );
$row= mysql_fetch_array ($numresults);
//store record id of every item that contains the keyword in the array we need to do this to avoid display of duplicate search result.
do{
$adid_array[] = $row[ 'id' ];
}while( $row= mysql_fetch_array($numresults));
} //end foreach
//Display a message if no results found
if($row_num_links_main == 0 && $row_num_links_main1 == 0){
$resultmsg = “Search results for: “. $trimmed.”Sorry, your search returned zero results” ;
}
//delete duplicate record id’s from the array. To do this we will use array_unique function
$tmparr = array_unique($adid_array);
$i=0;
foreach ($tmparr as $v) {
$newarr[$i] = $v;
$i++;
}
//total result
$row_num_links_main = $row_num_links_main + $row_num_links_main1;
What’s wrong?
Peace
Robin
I got double search results when I search for example “text text”. Do you know what’s wrong? The code is in the post above me.
eplicanic
Take a look at the line 122 of the tutorial code. When you compare it to yours, you’ll notice that the display part is outside of the foreach loop. Make that adjustment and let me know if that worked.
Robin
It works. Thank you very much for your help. I only have one error left, which I can not fix. The word you have searched for is not displayed in bold text, it proffers some Chinese characters.
Here is the code for it:
//create summary of the long text. For example if the field2 is your full text grab only first 130 characters of it for the result
$introcontent = strip_tags($row_linkcat[ 'text']);
$introcontent = substr($introcontent, 0, 130).”…”;
//now let’s make the keywods bold. To do that we will use preg_replace function.
//Replace field
$title = preg_replace ( “‘($var)’si” , “\1” , $row_linkcat[ 'title' ] );
$desc = preg_replace ( “‘($var)’si” , “\1” , $introcontent);
$link = preg_replace ( “‘($var)’si” , “\1” , $row_linkcat[ 'url' ] );
foreach($trimmed_array as $trimm){
if($trimm != ‘b’ ){
$title = preg_replace( “‘($trimm)’si” , “\1” , $title);
$desc = preg_replace( “‘($trimm)’si” , “\1” , $desc);
$link = preg_replace( “‘($trimm)’si” , “\1” , $link);
}//end highlight
}//end foreach $trimmed_array
eplicanic
Replace “\1″ with “\\1″ (double slash) ! Hopefully this will work!
Robin
Now everything works! Thank you for taking the time to help me. :)
hasim
It doesn’t work when I hit ‘next’ link to turn page. What should I do? Is it about register global setting?
eplicanic
What exactly does it do? If you view source of the HTML page how does the ‘next’ lik look?
Ishan
PHP Error Message
Warning: mysql_connect() [function.mysql-connect]: Access denied for user ‘a8694049′@’10.1.1.40′ (using password: YES) in /home/a8694049/public_html/search.php on line 7
Free Web Hosting
Unabale to connect to the database
eplicanic
Double check your database connection info: username, password etc.
nayya
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\se_2\searcheng.php on line 48
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\se_2\searcheng.php on line 54
Couldn’t execute query
i am getting this error please resolve
eplicanic
Double-check and make sure your queries syntax is correct!
keerthi
my problem is that the entire text is being displayed.i only want to display the sentence in which my search word is included.
please help me
Anthony
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/gamercol/public_html/search.php on line 49
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/gamercol/public_html/search.php on line 55
Couldn’t execute query
“Double-check and make sure your queries syntax is correct!”
how can i do this?
sorry, im new to php and msql
Spadez
I see the script expects a database, where can i get a sample db to test this script?
thanks
Nemanja Ristic
Thanks for excelent work. It really helped me to learn something new and how something works.
Greetings from Banja Luka, Bosnia and Herzegowina
eplicanic
Hvala Nemanja! :)
Antony
I get. Help
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource at line 49
German
Hi eplicanic, i am willng to pay u thru paypal if you can make this work on my website… i am having a hard time trying to display results and its just too annoying for me, plus i want also to be able to order the results asc or desc by clicking a button and as well as by user name, newest / older member, age, etc etc etc..
eplicanic
If you’re not familiar with PHP you could easily achieve sorting using jQuery plugins such as http://tablesorter.com/docs/#Introduction
Nilpo
You really should mention that this script works most effectively on databases that use FULLTEXT indexing. There is a redundant fallback using LIKE, but that could be very, very slow depending upon the size and nature of the dataset.
As a general rule of thumb, database-driven search engines work best with properly indexed, properly rationalized databases.
Gubi
ya very nice
Ganpat Singh Rathore
I Like, it is usefull and very nice ;)
Ganpat Singh Rathore
I Like, it is useful and very nice ;)
H.A.D.Chamara
it is use full and easy to understand.. thank you…………!!!!!!!!!
Suraj Kumar
Hi, Can any of you guys tell me good sources to start learning PHP and MySQL .
Adam Orama
Some good sources can be me, the PHP.NET Website, and etcetera. ;)
vivek
Instead of one table i want to search in whole MySQL daabase. So, any idea?
Ben
Hi. I purchased your script and followed the instructions very carefully
filling in all the sections you mentioned and I’m getting this error no matter what I type in the search….
“Search Error
Your keyword has to be at least two characters long! ”
Any help would be ace. thanks!
sola
Thanks for the code…
Am sure its working with the rest guys and however am having issues…and yes i expect you would expect its my query but i still dont get…
! ) Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\Greencat\searcher.php on line 41
and so couldnt execute query.
Thanks again.
Ben
Can I get an update please? Still not got it working…
Cheers.
stella
wonderful code!
but am having error message in lines
if($row_num_links_main == 0 && $row_num_links_main1 == 0){
and
$row_num_links_main = $row_num_links_main + $row_num_links_main1;
the error is showing undefined variable: row_num_links_main1
and also
mysql_num_rows() expects parameter 1 to be resource, boolean given in line
$row_num_links_main =mysql_num_rows($numresults);
I dont know how to correct this, Please advise me.
eplicanic
I made some changes to the code. Give it a try now.
shariqeu ahmad
I tried your code 2 to 3 times but i get some error messages. Your code is very difficult, your method is very bad, this is only time consuming process as nothing to get any knowledge. Please dont waste public time. ok
eplicanic
Sorry you couldn’t get it to work. Once I find some more time I’ll clean up the displayed code a bit. The download version however is constantly updated. I sent it to you in an email. Give it a try and let me know if it worked better for you.
jovazel
can you send to me your sample codes sir. i really need searching code for my project. thanks in advance.
Ahmed
How I get in contact with you?
Can you give me your email?
Thanks,
Payam
Thanks for the code as well, but I am getting an error that I don’t quite understand why even though the code generates search results properly. Is there a php.ini setting that is causing the foreach query to generate this warning: /search.php on line 74: mysql_num_rows(): supplied argument is not a valid MySQL result resource. Below is a few lines leading up to line 74 in my code which is the last line below.
// Build SQL Query for each keyword entered
foreach ($trimmed_array as $trimm){echo ‘YES’;
// EDIT HERE and specify your table and field names for the SQL query
// MySQL “MATCH” is used for full-text searching. Please visit mysql for details.
$query = “SELECT * , MATCH (title, description) AGAINST (‘”.$trimm.”‘) AS score FROM pm_events WHERE MATCH (title, description) AGAINST (‘+”.$trimm.”‘) ORDER BY score DESC”;
// Execute the query to get number of rows that contain search kewords
$numresults=mysql_query ($query);
$row_num_links_main =mysql_num_rows ($numresults);
Andy
Hi there. I’ve implemented the code, updated the database connection with my info and changed the table and field names to the proper table names, but when the page loads, it just says, “Search Error. Please enter a search…”. When I enter a term and search, it just shows, “Search results for: term
…
Next ”
Not sure where to even begin troubleshooting. I’d be happy to download, but am not willing to if I’m going to get the same unknown issues. Any help would be greatly appreciated. Thank you.
Andy
** Updated. I found some potential issues. Feel free to delete earlier post. However, some of the results do not contain the bolded search criteria so how can I be sure that the search code is working correctly?
Thanks and sorry to bother.
eric
I had the same issue then I noticed on line 117 you need to update the “news_id” value if your table uses something else for example I did not get any search results until I updated the “news_id” value to “ID” since that was the primary key for my table
do{
$adid_array[] = $row[ 'news_id' ];
}while( $row= mysql_fetch_array($numresults));
}
Hope that helps
Eric
zathway
Thankyou Elicanic for the coding it helps our website very much, but we have this error
“Parse error: syntax error, unexpected T_STRING in C:\inetpub\vhosts\zathway.com\httpdocs\search.php on line 45″
Please tell us the changes we have to do to the coding
eric
I received the updated code zip but cannot get it to play nice with my database config. I always get this error
Error in query: SELECT *, MATCH (Ename,Edetails) AGAINST (‘Eric’) AS score FROM Events WHERE MATCH (Ename,Edetails) AGAINST (‘+Eric’ IN BOOLEAN MODE) HAVING score > 0.01 ORDER BY score DESC. Can’t find FULLTEXT index matching the column list
I am not sure if this is caused by the table properties or how I entered the configuration in the start of your script.
It would be great if you would include a small testing mysql DB in the zip that worked with the search-example.php file
Thanks,
Eric
eplicanic
The script should alter your table to include fullindex automatically if it needs to. Not sure why it didn’t do it for you. Here is some info about it: http://dev.mysql.com/doc/refman/5.0/en/create-index.html
Sorry I can’t be of more help right now. Here is why: http://www.theuntour.com ;)
eric
Just ran this SQL to manually fix the index issue
ALTER TABLE table_name ADD FULLTEXT name_of_index(field1,field2,field3);
also
Jena
I just downloaded the supported version and have a setup question. Sorry I need you during your inspiring bike tour (but I do).
What does the table row ID refer to? I don’t know what to fill in here.
Mitchell Bray
direct copy and paste i get
Parse error: syntax error, unexpected T_VARIABLE in /Users/iMac/Sites/SearchEngine/test.php on line 12
line 12:
$limit = 10;
any idears?
jigar
thanks buddy !!!!!!!!!!!!
Henson
hi,, i got an error.. it says “Couldn’t execute query”
i have been finding what went wrong.. please help.. i just saved your code as search.php but still no luck.
this is my index.php
Search the Database
Search:
please note that what i have edited on search.php is
$hostname_logon = “localhost” ;
$database_logon = “knowledgebase” ;
$username_logon = “root” ;
$password_logon = “password123″ ;
and the table name.
please help. thanks!
Mike Hickcox
I’m trying to find a script I can use to query 3 fields in a database with keywords, and then print out selected fields from all those records that match.
Can this script be adapted to do that?
Thanks.
Gila
Is it open source code? Can I take it and use it and update it?
eplicanic
Sure! As long as you give a credit where a credit is due. Good karma never hurt anyone ;)
Zion
Thank you For this Post, i will write my own script for this function but you have given me a good Starting point.
Also i read a few of the post’s others made saying what you “Should of done” but i think you have done Great, thanks for the Script.
nick
i’m working on a search engine for my website
i currently hold 2 major indexes, one is a pair value of words/word ids, and another pair values of product with word id.
currently the main index contains ~ 4 million pair values.
it takes my engine about 0.15-0.20 seconds to match against top 500-1000 results..
1.00-1.20 seconds to select 5000 or more results (up to 50,000 makes little difference)
my question is, how can I optimize SELECT to be more efficient? i want my queries to be no more than 0.25sec overall
first query finds the word id from the index in about 0.0004sec to 0.0005sec so it’s not a problem even for multiple words. that’s from a list of 260k
the problem comes in matching those word id’s versus an index of dozens of millions of results
what do you think
Evan
This is lame. 95 cents for the version that works? Why even post the script at the top of the page? it doesn’t work without alteration.
tendai
it doesnt really need to work.
it’s the concept that matters
Scott Levy
Nice post. I found this blog with withbest practices for creating a search form that is quick and easy to use http://blog.caspio.com/web-database/7-tips-for-creating-user-friendly-search-forms/
Job guaranteed training in PHP
I am Extremely thanks full for the author for posting such as great post to us.
Gab
Hi ,
I purchased the code today and i fill in all the required info (database and table credentials) i uploaded the “search-example.php” and “search.php” online but i got an error when i fill in and submit the search field:
Error in query: SELECT *, MATCH (items_name,items_pics) AGAINST (‘Vegetable’) AS score FROM tbl_sinno_items WHERE MATCH (items_name,items_pics) AGAINST (‘+Vegetable’ IN BOOLEAN MODE) HAVING score > 0.01 ORDER BY score DESC. Can’t find FULLTEXT index matching the column list
please help. thanks!
Gab
Also, do we have the possibility to search from 2 or 3 tables ?
paulo
does some have the db table code for this php search script? the one that is on this page…
thank you…
Isaac
Am get the following errors please
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\search\search.php on line 48
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\search\search.php on line 54
Couldn’t execute query
Am waiting for the reply please
Dele Oyediji
I paid to download the code and i didnt get anything
eplicanic
You should receive an email with download link. Please check your junk folders. If you don’t receive an email in next half hour let me know.
pdf
i want to use in my project.. thanks a lot.. Very usefull..
Hegra
Script looks nice, but does not work. I get: Undefined index: s in search.php on line 18 and several other errors.
tendai
I got to say this in shona “wakapenga mface”
This is a powerful algorithm.
Can’t wait to plug it into my site…
wassim
thanks for the nice script, there’s a problem though that when you navigate to the second page, some results appear again ( repeated ). Any ideas ?
& about the updated script, what does it have more ? and how much is the price ? Thanks :)
Erwin
The script appears to be working as when I run it without entering something to search for, it gives the proper error, “Search Error Please enter a search..” However, when I enter a keyword to be searched for, for example the word “name” which i have in the database, the results are “Search results for: name …” I have checked my code and updated database connection and tables. can you please help ASAP.
godfrey
i keep getting an error i am trying to connect a normaly php search engine with joomla user database… keeps saying
Parse error: syntax error, unexpected T_IF in C:\wamp\www\search\conn.php on line 11
Marco
I”m new to PHP and am a bit confused as to what is being asked.
Can someone post a complete script of a working site? minus db info. I think I have that down. I purchased your script thinking it would have a readme file with detailed instructions. This may not be the solution for me, but any help you can provide is greatly appreciated.
faves pad
I”m new to PHP and am a bit confused as to what is being asked.
Chris
I’ve paid but i didn’t received anythig on my e-mail. I’ve checked out the spam folder also.
eplicanic
I’m sorry about the trouble. I double checked the logs and for some reason the script didn’t generate the download link for you. I just generated the download link manually and emailed it to you :)
Chris
I’ve received the e-mail. Thanks for the script!
Tymon
Hi.
Great script. Thanks a lot. I have 2 issues.
1. on some queries the search will generate ‘empty’ results. There will be proper results but also 1 results for which it is like all the database entries are empty. This row obviously does not exist in the database.
2. If someone types a double space between 2 words in the query, e.g.: ‘hi there”, the script goes completely mental.
I’ve also had to replace $row_num_links_main =mysql_num_rows ($numresults); with if($numresults){$row_num_links_main =mysql_num_rows ($numresults);} to prevent an error from generating, just as a tip.
Any suggestions? Thanks!
Tymon
Is there a difference between what’s shown above and the downloadable one? I’ll happily pay 1$ if it fixes the issues I just don’t have a PayPal account.
londi
I am getting the Error:
Error in query: SELECT *, MATCH (Title,Content) AGAINST (‘name’) AS score FROM databasee WHERE MATCH (Title,Content) AGAINST (‘+name’ IN BOOLEAN MODE) HAVING score > 0.01 ORDER BY score DESC. Can’t find FULLTEXT index matching the column list
Any suggestions?
and btw what is ROW_ID in a phpmyadmin database?