Examples of character escape methods in mysql statements
| When inserting a string with single or double quotation marks in the mysql database, if it is a single string, you can consider escaping it with a backslash. what if a large amount of data needs to be converted? Refer to the introduction in this article.
If a large amount of content needs to be escaped, consider the mysql_real_escape_string function: mysql_real_escape_string-escape special characters in the strings used in SQL statements, and consider the connected current character set.
Note: This function does not escape % and _. In addition, it is best not to use this function for the entire SQL statement, but to only escape the string parameters passed into the SQL statement, otherwise it will appear quietly.
Example:
Test it in your own program to see how the escape result is. |