DasHaas Posted August 9, 2007 Share Posted August 9, 2007 I have a table that contains one column (words) this column has several rows, each contains a banned word. I want to check if one of the fields in my form contains one of these banned words, if it does halt everything and print an error. here is what i have so far, but it does not seem to work connect to database //check for banned words $query = "SELECT* FROM BannedWords"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); $row = mysql_fetch_array($result); if(substr_count("$long_desc","$row")>0) {echo 'BANNED WORD DETECTED';} any suggestions?? ??? Quote Link to comment https://forums.phpfreaks.com/topic/63997-detect-banned-words-from-mysql-table/ Share on other sites More sharing options...
Foser Posted August 9, 2007 Share Posted August 9, 2007 You might want to look into regex Quote Link to comment https://forums.phpfreaks.com/topic/63997-detect-banned-words-from-mysql-table/#findComment-319061 Share on other sites More sharing options...
cmgmyr Posted August 9, 2007 Share Posted August 9, 2007 it would probably be easier to do this before you enter the data into the database. but as Foser said you can easily do this with regex, just loop through your data and apply your regex. if you don't know how to do it there is a board on here that can help you. Quote Link to comment https://forums.phpfreaks.com/topic/63997-detect-banned-words-from-mysql-table/#findComment-319066 Share on other sites More sharing options...
teng84 Posted August 9, 2007 Share Posted August 9, 2007 if you really serious doing this then this is not going to be easy LOOOOK i can do something like this FxUxCx@@@ oops icant proceed the admin might yell at me or SUUUUUUUUUUUUUUUUUUUUU@@@@@ or F_U_C@@@@@@@@@@ there are lots of ways of indirect doing this Quote Link to comment https://forums.phpfreaks.com/topic/63997-detect-banned-words-from-mysql-table/#findComment-319068 Share on other sites More sharing options...
suttercain Posted August 9, 2007 Share Posted August 9, 2007 Couldn't you... <?php $text = "Why don't you go fick yourself and eat some shot azzhole!"; $banned = array('fick', 'shot', 'azz'); $filter = array('f*ck', 'sh*t', 'a**'); $cleaned = str_ireplace($banned, $filter, $text); echo $cleaned; ?> The above would echo Why don't you go f*ck yourself and eat some sh*t a**hole! Obvioulsy the banned would contain real curse words, and then you can use the $filter to replace the original with what ever you'd like. Quote Link to comment https://forums.phpfreaks.com/topic/63997-detect-banned-words-from-mysql-table/#findComment-319080 Share on other sites More sharing options...
DasHaas Posted August 9, 2007 Author Share Posted August 9, 2007 I am trying to keep the banned words in a table in my database so I do not have to maintain an array for each form. I think that eventually the list of words will be long. I want to run this check before I enter the data to the table. If the string does not contain banned words enter the data, if it contains banned words echo an error. I know how to do the if statement, I just do not know how to have php check my txt field against the words in my table that contains the banned words. Quote Link to comment https://forums.phpfreaks.com/topic/63997-detect-banned-words-from-mysql-table/#findComment-319318 Share on other sites More sharing options...
DasHaas Posted August 9, 2007 Author Share Posted August 9, 2007 any takers? Quote Link to comment https://forums.phpfreaks.com/topic/63997-detect-banned-words-from-mysql-table/#findComment-319351 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.