Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Bad words filter

Bad word filter with php and mysql



9:11 pm on May 15, 2004 (gmt 0)

Inactive Member
Account Expired


How can i go about getting a bad words filter that uses mysql for ease of editing , deleting , and adding filter words
--Thanks in advance
1:44 am on May 16, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 12, 2003
votes: 0

function edit_words($STRING,$bannedwords) {
foreach($bannedwords as $key => $v) {
$STRING = eregi_replace($v,"*@!\$",$STRING);
return $STRING;

//i don't know how to populate the list using mySQL, never used it
$words = array('this','that','and','the','other','thing');

// call it like this
$uneditedString = "hi, this and that and the other thing. yup!";
$edited = edit_words($uneditedString,$words);

hope this helps a little, i'm sure there are much better ways

4:22 pm on May 19, 2004 (gmt 0)

New User

10+ Year Member

joined:May 24, 2002
votes: 0

MYSQL_QUERY (SELECT * FROM bad words list.....



for($x=0; $x< count($badWords); $x++)
$input = eregi_replace($badWords[$x], "****", $input);


Replaces bad words with **** in $input


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members