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 1063421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:46:55+00:00 2026-05-16T18:46:55+00:00

this question had been evolving in my mind, how do i totally stop the

  • 0

this question had been evolving in my mind, how do i totally stop the users from entering some crazy SQL injections. isn’t mysql_real_escape_string powerful enough to stop it? i followed some guidelines though there were some users in here who criticized my code and gave me thumbs down for the security. i was unable to understand the reason behind it. though i am not using $_GET, the only user input is through commenting system. i just want to make sure i am not going wrong. here is my sample code.

$name = htmlspecialchars(strip_tags(mysql_real_escape_string($_POST['com_name'])));

I have used the same for some 5 fields. what is your take on my above code?

  • 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-16T18:46:55+00:00Added an answer on May 16, 2026 at 6:46 pm

    The idea is not to stop the users from entering it, but to make sure you enter them in the database query safely. This means using mysql_real_escape_string or using parameterized queries with mysqli:

    /* Prepare an insert statement */
    $query = "INSERT INTO myCity (Name, CountryCode, District) VALUES (?,?,?)";
    $stmt = mysqli_prepare($link, $query);
    
    mysqli_stmt_bind_param($stmt, "sss", $val1, $val2, $val3);
    

    You also need to make sure your properly html encode fields you read from the database, to avoid that the user is able to inject html (and also javascript)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question had been asked a hundred times, but I have difficulties
I know that this question had already been asked a couple of times before,
This question may have been asked before, but I had trouble finding an answer,
I always had this question: When i dont mind the exact floating number Which
I had asked this question Adding more attributes to LINQ to SQL entity Now,
This question has two parts. Part 1. Yesterday I had some code which would
EDIT: it turned out this question had been asked the wrong way — see
This question made me question a practice I had been following for years. For
So one of my previous exams had this question, and till now I've been
I know that this question had been asked many times, but every answer seems

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.