Examples of character escape methods in mysql statements

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.