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 Link to comment https://forums.phpfreaks.com/topic/283799-compilation-failed-nothing-to-repeat-at-offset-2322/ 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 \ Link to comment https://forums.phpfreaks.com/topic/283799-compilation-failed-nothing-to-repeat-at-offset-2322/#findComment-1457907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.