toonz Posted September 17, 2009 Share Posted September 17, 2009 I currently have a php file that runs when users submit text in certain fields around my site. Right now, the file only looks for specifics words I enter into a table, and it only finds exact words. What I want to do is have the sql tring be able to use wildcard values around the {invalid_word} tag so it can find and prevent a user from submitting text if a long word contains the text on my banned list. Like, if I banned the word hair, and someone tried using the word hairball, it would let them. This is what the current php file code is <?php # **** FIND BAD WORDS INTO THE ENTERED STRING **** # # @param $str - takes an argument as an string # match with database keywords # return true if bad word found # return false if bad word not found function findBadWords( $str ){ $return = false; if( strlen( $str ) > 0 ) { $sql = "SELECT * FROM tbl_invalidunm WHERE MATCH (invalid_word) AGAINST (LCASE('".$str."') IN BOOLEAN MODE)"; $rs = mysql_query( $sql ) or die( "Invalid query - ". mysql_error() ); if($rs){ $row_count = mysql_num_rows($rs); if( $row_count > 0 ) { $return = true; } } // if } // if return $return; } // end function ?> Thanks in advance for your help 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.