Jump to content

Recommended Posts

I have a table that contains one column (words) this column has several rows, each contains a banned word. I want to check if one of the fields in my form contains one of these banned words, if it does halt everything and print an error. here is what i have so far, but it does not seem to work

 

 

 

connect to database

//check for banned words
$query = "SELECT* FROM BannedWords";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
$row = mysql_fetch_array($result);

if(substr_count("$long_desc","$row")>0)
{echo 'BANNED WORD DETECTED';}

 

any suggestions?? ???

Link to comment
https://forums.phpfreaks.com/topic/63997-detect-banned-words-from-mysql-table/
Share on other sites

it would probably be easier to do this before you enter the data into the database.

 

but as Foser said you can easily do this with regex, just loop through your data and apply your regex. if you don't know how to do it there is a board on here that can help you.

if you really serious doing this then this is not going to be easy LOOOOK i can do something like this

 

 

FxUxCx@@@ oops icant proceed the admin might yell at me

or SUUUUUUUUUUUUUUUUUUUUU@@@@@

or F_U_C@@@@@@@@@@

 

there are lots of ways of indirect doing this 

Couldn't you...

 

<?php

$text = "Why don't you go fick yourself and eat some shot azzhole!";
$banned = array('fick', 'shot', 'azz');
$filter = array('f*ck', 'sh*t', 'a**');
$cleaned = str_ireplace($banned, $filter, $text);

echo $cleaned;

?>

 

The above would echo

Why don't you go f*ck yourself and eat some sh*t a**hole!

 

Obvioulsy the banned would contain real curse words, and then you can use the $filter to replace the original with what ever you'd like.

 

 

I am trying to keep the banned words in a table in my database so I do not have to maintain an array for each form. I think that eventually the list of words will be long. I want to run this check before I enter the data to the table. If the string does not contain banned words enter the data, if it contains banned words echo an error. I know how to do the if statement, I just do not know how to have php check my txt field against the words in my table that contains the banned words.

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.