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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:40:44+00:00 2026-05-24T02:40:44+00:00

http://php.net/manual/en/function.mysql-real-escape-string.php : mysql_real_escape_string() calls MySQL’s library function mysql_real_escape_string, which prepends backslashes to the following

  • 0

http://php.net/manual/en/function.mysql-real-escape-string.php:

mysql_real_escape_string() calls MySQL’s library function
mysql_real_escape_string, which prepends backslashes to the following
characters: \x00, \n, \r, \, ‘, ” and \x1a.

Ok, so basically if i ever do something like this:

mysql_query("insert T(C)select'".mysql_real_escape_string($value)."'")

I’m making 1 trip to the database for the mysql_real_escape_string function and another trip for the function mysql_query = 2 trips to the database?

  • 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-24T02:40:45+00:00Added an answer on May 24, 2026 at 2:40 am

    The fact that it uses the mysql library does not mean it does a round trip with the server.

    It runs code from the mysql client library, loaded in the same process as your php interpreter. You do need a connection though – that function needs to know some server settings to operate properly. But those settings are cached in the connection information on the PHP side.

    If you want to verify this (and you’re on linux), write a simple script like:

    <?php
    $link = mysql_connect('localhost', 'user', 'pass');
    echo "Connection done\n";
    echo mysql_real_escape_string("this ' is a test");
    ?>
    

    And run it through strace:

    $ strace php t.php
    ....            # here comes the connection to mysql, socket fd == 3
    connect(3, {sa_family=AF_FILE, path="/var/run/mysqld/mysqld.sock"}, 110) = 0
    fcntl(3, F_SETFL, O_RDWR)               = 0
    setsockopt(3, SOL_SOCKET, SO_RCVTIMEO, "\2003\341\1\0\0\0\0\0\0\0\0\0\0\0\0", 16) = 0
    ....            # talking with mysql here
    poll([{fd=3, events=POLLIN}], 1, 60000) = 1 ([{fd=3, revents=POLLIN}])
    read(3, "8\0\0\0\n5.1.58-log\0\3\0\0\0K-?4'fL+\0\377\367!"..., 16384) = 60
    ...
    read(3, "\7\0\0\2\0\0\0\2\0\0\0", 16384) = 11
                    # first php echo
    write(1, "Connection done\n", 16Connection done    )       = 16
                    # second php echo
    write(1, "this \\' is a test", 17this \' is a test)      = 17
    munmap(0x7f62e187a000, 528384)          = 0
    ....
    

    The only important thing there is that the two writes caused by the echo statements have no other syscall in between – no network communication is possible without a syscall (from userspace in linux anyway).

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

Sidebar

Related Questions

I saw this comment.... http://www.php.net/manual/en/function.mysql-real-escape-string.php#93005 And began to wonder why this would be a
http://php.net/manual/en/function.mysql-escape-string.php Why is that?
There is a function similar_text() in the PHP library. The documentation ( http://php.net/manual/en/function.similar-text.php )
I've tried this: http://be.php.net/manual/en/function.mysql-list-fields.php , but there's too much detail here. What I'm looking
Does anyone know of an equivalent function in MySQL of PHP's base_convert? http://php.net/manual/en/function.base-convert.php Thanks,
I am trying to validate a directory with C++. http://php.net/manual/en/function.is-readable.php bool is_readable ( string
I need an exactly opposite method of timezone_name_from_abbr(): http://php.net/manual/en/function.timezone-name-from-abbr.php I have a list of
Read some texts about locking in PHP. They all, mainly, direct to http://php.net/manual/en/function.flock.php .
From http://php.net/manual/en/function.mcrypt-encrypt.php , I saw the following codes using AES with an IV in
for example consider an url from php.net, let's be it: http://pl2.php.net/manual/en/function.time.php gmt time when

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.