Danny620 Posted November 11, 2013 Share Posted November 11, 2013 require_once('./140dev_config.php'); require_once('./db_lib.php'); $oDB = new db; $tweet_text = "Hello my name is user badword."; //Moderate tweet $query = 'SELECT profanity_id, profanity_word ' . 'FROM profanity_list'; $result = $oDB->select($query); $bad_words = array(); while($row = mysqli_fetch_assoc($result)) { $bad_words[] = $row['profanity_word']; } $matches = array(); $match_found = preg_match_all( "/\b(" . implode($bad_words,"|") . ")\b/i", $tweet_text, $matches ); if ($match_found) { echo $safe_to_show = 3; }else{ echo $safe_to_show = 1; } why does it not find the word badword Warning: preg_match_all(): Compilation failed: nothing to repeat at offset 2322 in /home/unlockth/public_html/twitter-server/db/badwords.php on line 23 1 Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted November 11, 2013 Share Posted November 11, 2013 your imploded string of bad words contains some regex syntax, something like ?*, at the 2322'th character position. any characters that have meaning in regex syntax will need to be escaped with a \ 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.