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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:32:01+00:00 2026-05-13T23:32:01+00:00

Is mysql_real_escape_string sufficient for cleaning user input in most situations? ::EDIT:: I’m thinking mostly

  • 0

Is mysql_real_escape_string sufficient for cleaning user input in most situations?

::EDIT::

I’m thinking mostly in terms of preventing SQL injection but I ultimately want to know if I can trust user data after I apply mysql_real_escape_string or if I should take extra measures to clean the data before I pass it around the application and databases.

I see where cleaning for HTML chars is important but I wouldn’t consider it necessary for trusting user input.

T

  • 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-13T23:32:02+00:00Added an answer on May 13, 2026 at 11:32 pm

    mysql_real_escape_string is not sufficient in all situations but it is definitely very good friend. The better solution is using Prepared Statements

    //example from http://php.net/manual/en/pdo.prepared-statements.php
    
    $stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (?, ?)");
    $stmt->bindParam(1, $name);
    $stmt->bindParam(2, $value);
    
    // insert one row
    $name = 'one';
    $value = 1;
    $stmt->execute();
    

    Also, not to forget HTMLPurifier that can be used to discard any invalid/suspicious characters.

    ………..

    Edit:
    Based on the comments below, I need to post this link (I should have done before sorry for creating confusion)

    mysql_real_escape_string() versus Prepared Statements

    Quoting:

    mysql_real_escape_string() prone to
    the same kind of issues affecting
    addslashes().

    Chris Shiflett (Security Expert)

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

Sidebar

Ask A Question

Stats

  • Questions 543k
  • Answers 543k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you're using VB.Net 2010, you can use a lambda… May 17, 2026 at 6:31 am
  • Editorial Team
    Editorial Team added an answer According to Microsoft, "Extension methods are a special kind of… May 17, 2026 at 6:31 am
  • Editorial Team
    Editorial Team added an answer Check this for a cool tool: http://www.codeproject.com/KB/macros/resorg.aspx- Another useful post:… May 17, 2026 at 6:31 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Im using smarty and mysql_real_escape_string() for user input, and when I insert some code
so i use mysql_real_escape_string to sanitize some user input before entering it into the
Is the following good enough to avoid a SQL injection? mysql_real_escape_string(htmlentities (urlencode($_POST['postmessage'])));
Just wondering, to sanitize user input, I use mysql_real_escape_string() on data before it is
mysql_real_escape_string is used for SQL statements. Is it enough for database security alone? For
How can I add mysql_real_escape_string() to this::: $result = mysql_send(INSERT customers SET user='$username', pword='$pass1',
Am I doing this right? Will this help avoid sql injections? $deleteid = htmlspecialchars(strip_tags(mysql_real_escape_string($_POST['listid'])));
mysql_real_escape_string and addslashes are both used to escape data before the database query, so
if (isset($_POST['login'])) { $query = mysql_query(" SELECT id FROM users WHERE username = '".mysql_real_escape_string($_POST['username'])."'
MySQL has this incredibly useful yet proprietary REPLACE INTO SQL Command. Can this easily

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.