phpsycho Posted September 26, 2011 Share Posted September 26, 2011 Okay so here is my query: $sql = "SELECT * FROM `search_links` WHERE MATCH(`keywords`,`description`,`title`) AGAINST ('$keywords' IN BOOLEAN MODE) ORDER BY `realdesc` DESC, `realkey` DESC LIMIT $skip, 15"; that works perfect but I get results that have inappropriate links desc etc so I would like to filter them.. I tried: $banned = "-sex -porn -anal"; //etc $sql = "SELECT * FROM `search_links` WHERE MATCH(`keywords`,`description`,`title`) AGAINST ('$keywords $banned' IN BOOLEAN MODE) ORDER BY `realdesc` DESC, `realkey` DESC LIMIT $skip, 15"; That works fine, but when I want to filter results with two words it won't work.. example: $banned = "-word1 word2 -word3 word4"; //doesn't work.. $banned = "-\"word1 word2\" -\"word3 word4\""; //doesn't work either $banned = "-(word1 word2) -(word3 word4)"; //and of course this doesn't work either.. soo I tried doing.. $sql = "SELECT * FROM `search_links` WHERE `title` NOT IN ('sex','porn') AND MATCH(`keywords`,`description`,`title`) AGAINST ('$keywords' IN BOOLEAN MODE) ORDER BY `realdesc` DESC, `realkey` DESC LIMIT $skip, 15"; and that doesn't filter or do anything at all.. How can I filter results inside the query? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/247901-filter-inappropriate-search-results/ Share on other sites More sharing options...
phpsycho Posted September 26, 2011 Author Share Posted September 26, 2011 huh.. found something odd.. if I use: $banned = "-sex"; it doesn't block out any results with the word sex in it. But.. if I $banned = "-porn"; it will block those. Whats with that? Quote Link to comment https://forums.phpfreaks.com/topic/247901-filter-inappropriate-search-results/#findComment-1272978 Share on other sites More sharing options...
phpsycho Posted September 27, 2011 Author Share Posted September 27, 2011 wow this is like the strangest thing I have seen.. It just totally ignores the word sex. I put the word sex in each the title desc and keywords and then the $banned var like this: $banned = "-sex -Sex -SEX"; still shows the results containing the word sex. But like I said before -porn will remove all results containing 'porn'. I also tried just matching `title` or `description` or `keywords` and then against my keywords(search term) and -sex still don't work. Quote Link to comment https://forums.phpfreaks.com/topic/247901-filter-inappropriate-search-results/#findComment-1273041 Share on other sites More sharing options...
Pikachu2000 Posted September 27, 2011 Share Posted September 27, 2011 See the first bulleted paragraph here: http://dev.mysql.com/doc/refman/5.5/en/fulltext-fine-tuning.html Quote Link to comment https://forums.phpfreaks.com/topic/247901-filter-inappropriate-search-results/#findComment-1273080 Share on other sites More sharing options...
phpsycho Posted September 27, 2011 Author Share Posted September 27, 2011 Ah! okay thanks! Only question I have now is how do I combine two words? like I said before.. -word1 word2 -"word1 word2" -(word1 word2) all don't seem to work right. Any idea? Quote Link to comment https://forums.phpfreaks.com/topic/247901-filter-inappropriate-search-results/#findComment-1273091 Share on other sites More sharing options...
Pikachu2000 Posted September 27, 2011 Share Posted September 27, 2011 In what way do they not seem to work right, specifically? Quote Link to comment https://forums.phpfreaks.com/topic/247901-filter-inappropriate-search-results/#findComment-1273094 Share on other sites More sharing options...
phpsycho Posted September 27, 2011 Author Share Posted September 27, 2011 huh never mind lol sorry it works now. -"word1 word2" I didn't realize what I was doing wrong.. keywords don't get echoed out but sense I am actually trying to filter out zoophilia content I searched for = "animal sex" and stuff showed up but not all had "animal sex" in the title or desc soo I thought okay if I then filter out -"animal sex" then I should only see those other results without those words in the title or desc. wrong of course lol basically just didn't think it out well, I was searching and filtering out the same thing Thanks for that link though, probably would have taken me a while to figure out there was a min char limit. Quote Link to comment https://forums.phpfreaks.com/topic/247901-filter-inappropriate-search-results/#findComment-1273097 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.