"'" In mysql

Source: Internet
Author: User
Mysql problems "select * from databases where 'name' = 'my name '"


An error occurs when my name is changed to I'm xiao. how can this problem be solved ????


"Select * from databases where 'name' = 'I'm xiao '"


Reply to discussion (solution)

1. "select * from databases where 'name' = 'my name '"
The field name is ', the symbol below ESC, not single quotes
2. I'm xiao has single quotation marks, so the single quotation marks in 'I'm xiao' will cause confusion.

Escape

Addslashes -- use a backslash to reference a string
Mysql_real_escape_string -- escape special characters in strings used in SQL statements and take into account the connected current character set

Use escape.

Addslashes first processes variables
Mysql_real_escape_string is directly used in SQL

Use escape characters to carefully check the code.

I cannot understand how to write

It is to add the \ symbol to escape with a special character.

It is to add the \ symbol to escape with a special character.

Positive solution on the second floor ~~~ Escape and OK ..

Your current SQL is easy to inject

Need to escape. addslash or mysql_real_escape_string

Try using escape!

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.