Phpmysql_escape_string and addslashes _ PHP Tutorial

Source: Internet
Author: User
Phpmysql_escape_string and addslashes. For details about the differences between phpmysql_escape_string and addslashes, refer to this article. The mysql_real_escape_string () function escapes special characters in strings used in SQL statements. For details about the differences between php mysql_escape_string and addslashes, refer to this article.

The mysql_real_escape_string () function escapes special characters in strings used in SQL statements.

The following characters are affected:

• X00
• N
• R
•
•'
•"
• X1a
If yes, the function returns the escaped string. If it fails, false is returned.


The addslashes () function adds a backslash before the specified predefined character.

The predefined characters are:

• Single quotes (')
• Double quotation marks (")
• Backslash ()
• NULL

Difference summary
The difference between mysql_escape_string and addslashes is that
Mysql_escape_string always converts "'" to "'"

And addslashes
Convert "'" to "'' "when magic_quotes_sybase = on
Convert "'" to "'" when magic_quotes_sybase = off

Http://www.bkjia.com/PHPjc/629045.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/629045.htmlTechArticlephp mysql_escape_string and addslashes detailed differences, you can refer to this article. The mysql_real_escape_string () function escapes special characters in strings used in SQL statements. The following words...

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.