stawkerm0h Posted March 9, 2011 Share Posted March 9, 2011 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" ?> Quote Link to comment https://forums.phpfreaks.com/topic/230100-need-help-in-php-and-in-sql/ Share on other sites More sharing options...
RussellReal Posted March 9, 2011 Share Posted March 9, 2011 just add a new word to the table Quote Link to comment https://forums.phpfreaks.com/topic/230100-need-help-in-php-and-in-sql/#findComment-1185024 Share on other sites More sharing options...
stawkerm0h Posted March 10, 2011 Author Share Posted March 10, 2011 what will be the value for new word table and what will be it's name? "word"?? and the value?? here's my database and here's the list of my bad words please help thanks Quote Link to comment https://forums.phpfreaks.com/topic/230100-need-help-in-php-and-in-sql/#findComment-1185276 Share on other sites More sharing options...
RussellReal Posted March 10, 2011 Share Posted March 10, 2011 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.. Quote Link to comment https://forums.phpfreaks.com/topic/230100-need-help-in-php-and-in-sql/#findComment-1185363 Share on other sites More sharing options...
MadLittleMods Posted March 10, 2011 Share Posted March 10, 2011 maybe this will help: http://www.phpfreaks.com/forums/index.php?topic=326822.0 Quote Link to comment https://forums.phpfreaks.com/topic/230100-need-help-in-php-and-in-sql/#findComment-1185371 Share on other sites More sharing options...
stawkerm0h Posted March 10, 2011 Author Share Posted March 10, 2011 what is the value for the new table "word"... is it varchar??primary,not null and auto-increment? Quote Link to comment https://forums.phpfreaks.com/topic/230100-need-help-in-php-and-in-sql/#findComment-1185404 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.