Escape special characters in unescaped_string. Considering the connection settings of the current character, it is safe in mysql_query (). If binary data is to be inserted, this function must be used. mysql_real_es... escape special characters in unescaped_string. Considering the connection settings of the current character, it is safe in mysql_query (). If binary data is to be inserted, this function must be used.
Mysql_real_escape_string-use strings in SQL statements that escape special characters
String mysql_real_escape_string (string $ unescaped_string [, resource $ link_identifier])
Mysql_real_escape_string () calls the MySQL library function mysql_real_escape_string. the prepends backslash contains the following characters.
This function must always (except a few exceptions) be used to secure MySQL data queried before sending.
Unescaped_string:Escape this string
Link_identifier,MySQL connection. If no connection identifier is specified, the mysql_connect () function is opened in the last link. If no such link is found, it will try to create a connection like mysql_connect () yes, no parameter call is required. If no connection is found or a connection is established, an E_WARNING-level error will be generated later.
Example 1: The code is as follows:
Example 2: The code is as follows:
Send the query to MySQL: SELECT * FROM the user's WHERE user = 'Adan 'and password = ''or'' = '', which will allow anyone to log on without a valid password.
Address:
Reprinted at will, but please attach the article address :-)