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

  • Home
  • SEARCH
  • 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 7963531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:37:40+00:00 2026-06-04T05:37:40+00:00

I’m going create database table badwords to store some unwanted words [ id,word ]

  • 0

I’m going create database table badwords to store some unwanted words [id,word] as following.

CREATE TABLE `badwords`(
`id` int(3) NOT NULL auto_increment,
`word` text,
PRIMARY KEY (`id`),
KEY `id` (`id`))

let say i’ve stored the following words

(1,ugly)
(2,yak)

Now my visitors might post some links contains one of those bad words and i’m willing to use something like this.

$user = "http://www.this_ugly_site.com"; // visitor post this (ugly) word within

// i'm gonna try to find any of bad words stored in my table

$qry="select * from badwords where word='$user'"; // how to do it (find)
$result=mysql_query($qry) or die($qry);
if(mysql_num_rows($result)=='0'){

echo "Good URL";

}else{

while($line=mysql_fetch_array($result)){

echo "Bad URL";

}}

I do not know how to apply strpos and if it really good solution or there is something else i can use !

or can i use

$qry="select * from badwords where word LIKE '%$user%'";

but it looks un-secure as it embedded a user-provided value into your SQL

so any idea or help how to do it ~ thanks

  • 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-06-04T05:37:41+00:00Added an answer on June 4, 2026 at 5:37 am

    You’ve asked 3 separate questions:

    1. How do I use strpos()

      It’s a native PHP function that takes three parameters. I’d encourage you to use and learn the PHP Docs. Nonetheless, here is an example:

      strpos($string, $bad_word);
      
    2. Is there a better way?

      Likely. But what you have isn’t bad. strpos() is one of the faster string functions. If you had thousands of bad words and a large amount of requests per second, then you’d likely want to look into caching the bad words instead of querying MySQL every time. However, no need to prematurely optimize. For now, fail early. That is when you find a bad word, break out of the loop.

    3. How do you escape a string in MySQL?

      I’d encourage you to use the MySQLi extension and then mysqli->real_escape_string().

      For example:

      $qry = "SELECT * FROM badwords WHERE word LIKE '%" . $dbc->real_escape_string($user) . "%'";
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I need a function that will clean a strings' special characters. I do NOT

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.