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
https://forums.phpfreaks.com/topic/230100-need-help-in-php-and-in-sql/
Share on other sites

uhm.. go to the top, pick 'insert'

 

then where it says 'word' insert the new bad word...

 

then where it says replacement.. doesn't matter what you put, you don't use that field, hit save, and you're done, BINGO new word added..

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.