Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7552951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:54:58+00:00 2026-05-30T10:54:58+00:00

Objective : I’d like to store certain words inside database table as banned words

  • 0

Objective : I’d like to store certain words inside database table as banned words to not to be used within posts.

I’ve asked how to apply banned words application using database Banned words application using database table and thanks for all answers.

But i’ve some changes would like to apply but 1st here is the new code

1- Created simple form to input the words to be banned (ban.php)

<form name="form" method="post" action="add.php">
<input type="text" name="bad" id="bad">
<input type="submit" name="submit" id="submit" size="12" value="submit">
</form>

2 – Now will post it through db (add.php)

<?PHP
require_once("config.php"); // db conn
$bad = $_POST['bad'];
$bad = mysql_real_escape_string($bad);

$sql= "insert into my_table set bad='$bad'";
mysql_query($sql, $conn) or die(mysql_error());

echo "Done bad word added";
?>

3- Example (1) ~ thanks to Robjong for previous help ~

<?PHP
require_once("config.php"); // db conn

$test = "ugly"; // Example

$qry = "SELECT * FROM `my_table` WHERE bad='{$test}'"; // select by value
$result=mysql_query($qry);

if( mysql_num_rows( $result ) ){ // we have a row with the 'bad' word
echo "banned";
}else{
echo "passed";
}
?>

Now my question Example (2)

What if i want to say if any of the stored words in my_table is found within $test then give echo "banned";

Just like this

<?PHP
require_once("config.php"); // db conn

$test = "hello world this is sentence with ugly word"; // 'ugly' word found


if( any stored words in my_table found within $test ){ 
echo "banned";
}else{
echo "passed";
}
?>

so how to do example (2) ?! that would helps me a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:55:00+00:00Added an answer on May 30, 2026 at 10:55 am

    I think it would be faster to pull out all of the banned words from your table and do the processing in PHP – rather than do the processing in MySQL. For that you would first select out each of the strings from the banned words table and put them in an array.

    Once you have done that you can then use array_intersect to see if any of the words are within the string e.g.

    //ASSUMES AN ARRAY OF BANNED WORDS $banned_words AND A STRING TO CHECK $str_check
    
    if(count(array_intersect(array_map('strtolower', explode(' ', $str_check)), $banned_words) > 0) {
        echo "banned";
    }
    else {
        echo "not banned";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Objective-C has no namespaces; it's much like C, everything is within one global namespace.
Objective: Be able to nest a resource, like records inside of users so that
Objective: I would like to reset the array attribute of all objects in a
In Objective-C, what does (UIButton *)sender mean and why is it not UIButton *sender?
In Objective-C, I've used Three20's TTUrlRequest to enable some simple caching of my web
Objective: I would like to be able to list the available COM Ports on
Objective was: To change pages like details.aspx?GUID=903901823908129038 to clean ones like /adrian_seo Achieved: Now
Objective-C is a language like Smalltalk, but weakly, dynamically typed language. And I can
Objective-C doesn't support methods overloading. Why? Is it doable but Apple decided not implement
Objective: I would like to take a JSON String and pass it into JavaScript

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.