Jump to content

badwords from query


dk4210

Recommended Posts

Hi guys,

 

I have the following code, How can I query the database for the bad words and the replacements and make it work.

 

 $ad_title2 = $ad_title;
  $ad_body2  = $ad_body;
  $wordlist = "sh%t:cr*p|dang:d*ng|shoot:sh**t";
  $words = explode('|', $wordlist);
  foreach ($words as $word) {
  list($match, $replacement) = explode(':', $word);
  $ad_title2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $ad_title2);
  $ad_body2 = preg_replace("/([^a-z^A-Z]?)($match)([^a-z^A-Z]?)/i", "$1".$replacement."$3", $ad_body2);
  }

 

Here is my table structure

Table name is badwords

 

I have 3 columns

 

id | word | r_word

 

 

Any help would be greatly appreciated!

 

 

 

 

 

Link to comment
Share on other sites

Try:

 

Find:

$wordlist = "sh%t:cr*p|dang:d*ng|shoot:sh**t";

 

Replace:

$search_for_bad_words = mysql_query("SELECT * FROM badwords WHERE 1");

$seperate_text = "|";
$entry_seperate_text = ":";

while($row = mysql_fetch_array($search_for_bad_words))
{
     $wordlist = $wordlist.$seperate_text.$row[word].$entry_seperate_text.$row[r_word];
}

Link to comment
Share on other sites

what do this code do??please explain

$wordlist = "sh%t:cr*p|dang:d*ng|shoot:sh**t";

 

 

and also this one?? please explain too

$seperate_text = "|";
$entry_seperate_text = ":";

while($row = mysql_fetch_array($search_for_bad_words))
{
     $wordlist = $wordlist.$seperate_text.$row[word].$entry_seperate_text.$row[r_word];
}

Link to comment
Share on other sites

Hi stawkerm0h,

 

This whole script is a filtering script when you need to filter out specific words when you have a form with text fields and textareas.

 

This code here basically  lists the words to filter and their replacement. Like the second one. Let's say the user enters the word "dang" it will be replaced by d*ng (It's separated by the :)

$wordlist = "sh%t:cr*p|dang:d*ng|shoot:sh**t";

 

This code here does the same thing EXCEPT it queries the database for the words instead of having a static word list

$seperate_text = "|";
$entry_seperate_text = ":";

while($row = mysql_fetch_array($search_for_bad_words))
{
     $wordlist = $wordlist.$seperate_text.$row[word].$entry_seperate_text.$row[r_word];
}

 

Hope this helps!

Link to comment
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.