Jump to content

Need help in PHP and in SQL


stawkerm0h

Recommended Posts

do i need to create another database for this??

because i already have the database of bad words...

if i need to create new....please help how and what will be the value for each field...

 

<?php
include('../../includes/inc.conn.php');

function swear_filter($string)
{
  $words = array();
  $query = "SELECT word FROM bad_words";
  $result = mysql_query($query) or die(mysql_error());
  while($row = mysql_fetch_array($result)){
    $words[] = '/\b' . $row['word'] . '\b/i';
  }
  return preg_replace($words, '***', $string);
}

$string_to_check = "My shitzu took a Shit on the carpet.";
echo swear_filter($string_to_check);

//Assuming the word 'shit' is in the db results
//Output: "My shitzu took a *** on the carpet"
?>

 

 

 

 

 

 

 

 

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.