This article is a mirror article of machine translation, please click here to jump to the original article.

View: 8548|Reply: 0

PHP - mysql_real_escape_string() vs. mysql_escape_string()

[Copy link]
Posted on 2/17/2015 9:31:20 AM | | |

1. Similarities:
Both can escape special characters in query strings
(characters that can be escaped)
\x00
\n
\r
\
'
"
\x1a
(Characters that cannot be escaped)
%
_

2. Differences:
(1)mysql_real_escape_string()
1) It has two parameters
parameter string, required. Specifies the string to be escaped.
parameter connection, optional. Specify MySQL connections. If not specified, the previous connection is used.

(2) The function takes into account the character set of the current database link when escaping, mysql_escape_string() does not have this function

(3) Before using it to escape the query string, a database connection must be established first, otherwise the function will always return bool(false)

(2) mysql_escape_string() has only one parameter string, and you don't need to establish a database connection before using it




Previous:IBM Mail Server x236 series
Next:PHP message: PHP Deprecated: mysql_escape_string()
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com