iscnetwork Posted June 12, 2012 Share Posted June 12, 2012 Hello to all and thanks in advance for your assistance. I am never going to be a good programmer. Butch I have 2 sets of code that I cannot put together and make work. I am trying to have a search of a concordance. But I want to keep out stupid words like they, them, etc. that just take up horsepower. I included a 'space' figuring that would take out multiple word searches. I need one other thing which I had no clue about; stop all searches for words under 3 characters long or contain numbers. <?php $forbiden_word=" "||"them"||"they"; # if $forbiden_word matches the submited word if($_POST['keysearch']==$forbiden_word) { $message='The word: '.$forbiden_word.' is not allowed.'; } else ?> <?php echo $message; ?> <form method="post" action="result.php" name="keysearch" onSubmit="<?php echo $_SERVER['REQUEST_URI']; ?>" /> <h3>Enter single word at least 3 characters long.</h3> <input type="text" name="search" value="" size="40" /><br /> <input type="submit" value="Display Results" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/264072-block-out-certain-words-from-search/ Share on other sites More sharing options...
Barand Posted June 12, 2012 Share Posted June 12, 2012 if you are using a database, look at FULLTEXT searches. This filters out many "stupid" words for you Quote Link to comment https://forums.phpfreaks.com/topic/264072-block-out-certain-words-from-search/#findComment-1353291 Share on other sites More sharing options...
ManiacDan Posted June 12, 2012 Share Posted June 12, 2012 If you're using MySQL's MATCH...AGAINST syntax (which was designed exactly for this kind of search) you can put words into MySQL's stopword list and have the database exclude them automatically. Barand and I are suggesting the same thing. MATCH...AGAINST is applied against columns with a FULLTEXT index. Google for either. Quote Link to comment https://forums.phpfreaks.com/topic/264072-block-out-certain-words-from-search/#findComment-1353295 Share on other sites More sharing options...
iscnetwork Posted June 12, 2012 Author Share Posted June 12, 2012 NO MySQL Just flat text database. (it is a give away so anyone can put on their website; and never need tech support). butch Quote Link to comment https://forums.phpfreaks.com/topic/264072-block-out-certain-words-from-search/#findComment-1353304 Share on other sites More sharing options...
ManiacDan Posted June 13, 2012 Share Posted June 13, 2012 Ugh, why? You could just as easily include a mysqldump file. You probably want to simply use empty(), strtolower() and in_array(). Quote Link to comment https://forums.phpfreaks.com/topic/264072-block-out-certain-words-from-search/#findComment-1353348 Share on other sites More sharing options...
iscnetwork Posted June 13, 2012 Author Share Posted June 13, 2012 You just describe items way above my PHP levels. Also the rest of the program is very tight so I don't know how half of it works. The receivers are even less knowledgeable than myself. If this helps here is what I am trying to tune... http://www.christianlibrary.org/bibles/bs/advancedsearch.php I have found people putting in 'a' just for the stupidity of it. thanks, butch Quote Link to comment https://forums.phpfreaks.com/topic/264072-block-out-certain-words-from-search/#findComment-1353358 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.