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

Source: Internet
Author: User
For mysql escape character insertion, query, and display problems, obtain special characters for mysql escape characters.

RT, which is a single quotation mark in php + mysql. the "\" symbol is inserted in the addslashes () mode.

If $ varstr = test' \ is inserted, 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!


Reply to discussion (solution)

Http://php.net/manual/zh/function.mysql-real-escape-string.php

Http://php.net/manual/zh/function.mysql-real-escape-string.php
Ls is another escape method. I am talking about the addslashes method.
In addition to the above three questions, there are many details that need attention and are often confusing ..
For example, echo "\\\\\\\\\" stripslashes handles various strange phenomena.

Ask experts to sort the information.

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

Thank you ..

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.