Jump to content

syntax error, unexpected ':'


Go to solution Solved by Ch0cu3r,

Recommended Posts

Hi I'm currently having a syntex error with my bad words filter function

function filterBadWords($str)
{
	
	
    $result1 = mysql_query("SELECT word FROM StringyChat_WordBan") or die(mysql_error()); 
    $replacements = "x";
    
    while($row = mysql_fetch_assoc($result1))
    {
          $str = preg_replace('/\b' . $row['word'].'\b/ie', ':-x', $str);
    }  
    
    return $str;
}

 

Parse error: syntax error, unexpected ':' in /home/u342037492/public_html/chat2/page.php(1917) : regexp code on line 1

 
Fatal error: preg_replace(): Failed evaluating code: :-x in /home/u342037492/public_html/chat2/page.php on line 1917

I know its the :-x part causing the problem but how can I fix it?

 

and is there maybe a better way to do the filter because if I got the word "ass" in my list it will replace assassinate to  :-x :-xinate ?

Link to comment
https://forums.phpfreaks.com/topic/298228-syntax-error-unexpected/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.