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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:08:53+00:00 2026-05-30T00:08:53+00:00

I have an application which would greatly benefit by using dynamic mysql queries in

  • 0

I have an application which would greatly benefit by using dynamic mysql queries in combination with mysql (mysqli) real escape string. If I ran all data received from the user through mysql real escape would it be just as secure as using mysql prepared statements?

  • 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-30T00:08:56+00:00Added an answer on May 30, 2026 at 12:08 am

    Definitely NO.

    While question in the title is ambiguous and can be interpreted as “Are dynamic mysql queries with every it’s part properly formatted…” and thus have a positive answer, the question in the body is not:

    If I ran all data received from the user through mysql real escape would it be just as secure as using mysql prepared statements?

    If you look to this question closer, you will understand that this is just a magic quotes incarnation! The very purpose of this disgraced, deprecated and removed feature is exactly to “run all user input through escape”.
    Everyone knows nowadays that magic quotes are bad. Why positive answer then?

    Okay, it seems that it needs to be explained again, why bulk escaping is bad.

    The root of the problem is a quite strong delusion, shared by almost every PHP user:
    Everyone have a strange belief that escaping do something on “dangerous characters” (what are they?) making them “safe” (how?). Needless to say that it’s but a complete rubbish.

    The truth is:

    • Escaping do not “sanitize” anything.
    • Escaping has nothing to do with injections.
    • Escaping has nothing to do with user input.

    Escaping is merely a string formatting and nothing else.
    When you need it – you need it despite of injection possibility.
    When you don’t need it – it won’t help against injection even a little.

    Speaking of difference with prepared statements, there is at least one issue (which already mentioned many times under sql-injection tag):
    a code like this

    $clean = mysql_real_escape_string($_POST['some_dangerous_variable']);
    $query = "SELECT * FROM someTable WHERE somevalue = $clean";
    

    will help you NOT against injection.
    Beause escaping is just a string formatting facility, not injection preventer by any means.
    Go figure.

    However, escaping have something in common with prepared statements:
    Them both doesn’t guarantee you from injection if

    • you are using it only against notorious “user input”, not as a strict rule for the building ANY query, despite of data source.
    • in case you need to insert not data but identifier or a keyword.

    To be safe in these circumstances, see my answer explaining FULL sql injection protection how-to

    Long story short: you can consider yourself safe only if you make 2 essential corrections and one addition to your initial statement:

    If I ran all data received from the user through mysql real escape and always enclose it in quotes (and, as ircmaxell mentioned, mysqli_set_charset() is used to make mysqli_real_escape string() actually do it’s work (in such a rare occasion of using some odd encoding like GBK)) would it be just as secure as using mysql prepared statements?

    Following these rules – yes, it would be as secure as native prepared statements.

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

Sidebar

Related Questions

I have a c++ console application which I would like to publish using clickonce.
I have an application in which I would like to support multiple orientations. I
I have a Silverlight application in which I would like to call a WCF
I have an ASP.Net application which as desired feature, users would like to be
I am thinking of making an (initially) small Web Application, which would eventually have
I am new to iPhone world. I have developed an application, which I would
I have a web application that has a dynamic javascript calendar, which allows users
I have a GWT application which I would like to run from within a
I have an Java applications which I would like to run with different values
I have developed about 300 Applications which I would like to provide with multi-language

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.