For mysql escape character insertion, query, and display problems, Dial

Source: Internet
Author: User
Mysql escape character insertion, query, and display problems, dial RT, usually php + mysql single quotes, "\" symbol insertion generally uses addslashes () method & nbsp; if, insert $ varstr & nbsp ;=& nbsp; test' \. The problem is as follows: 1. with addslashes (), insert, insert, and then insert, query, and display mysq mysql escape characters.
RT, which is a single quotation mark in php + mysql. the "\" symbol is inserted in the addslashes () mode.

Assume that $ varstr = is inserted Test '\, The problem is as follows:
1. with addslashes (), after insert is inserted, the storage format in mysql is test' \, or test \'\\?

3. after the select statement is selected, echo $ varstr; is it test' \ or test \'\\?

2. do I need to add addslashes () when selelct queries with this variable string as the condition ()?

Mysql has a headache about escape characters. I hope experts can give me some help. thank you! Mysql? Escape character? Share special characters:
------ Solution --------------------
Http://php.net/manual/zh/function.mysql-real-escape-string.php
------ Solution --------------------
The storage format in mysql is test '\
Echo $ varstr; display as test '\

Do I need to add addslashes () when selelct queries with this variable string as the condition ()?
Yes

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.