MySQL escape character insertion, query and display problems, asking for a nudge

Source: Internet
Author: User
MySQL Escape character special characters

RT, usually php+mysql single quotes, "\" symbol insertion generally using addslashes () mode

If, now insert $varstr = Test ' \, the problem is as follows:
1. With addslashes (), insert after insert in MySQL storage format is test ' \, or test\ ' \ \?

3.select out, Echo $varstr; is the test ' \, or test\ ' \ \?

2.SELELCT do I need to add addslashes () when I query the variable string as a condition?

MySQL on the escape character problem, very headache, I hope the experts come out to the next, thanks!


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 This is another way of escaping, I'm talking about the addslashes way.
In addition to the above 3 questions, there are still a lot of details that need attention, often easily confused.
such as: echo "\\\\\\\\\" stripslashes handle all kinds of strange phenomenon.

Ask the experts to comb.

The storage format in MySQL is Test ' \
echo $varstr; display is test ' \

SELELCT do I need to add addslashes () when querying with this variable string?
To

Thanks, upstairs.

  • 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.