Basic phpmysql prevention of SQL attack injection

Source: Internet
Author: User
We use MagicQuotes that comes with php to determine whether it is enabled. if it is stripslashes, or else it will be filtered using mysql_real_escape_string. the instance code is as follows: if Magic... we use the Magic Quotes provided by php to determine whether it is enabled. if it is stripslashes, or else mysql_real_escape_string will be used for filtering. the instance code is as follows:

// If the Magic Quotes function enables if (get_magic_quotes_gpc () {$ name = stripslashes ($ name);} else {$ name = mysql_real_escape_string ($ name );} mysql_query ("SELECT * FROM users WHERE name = '{$ name }'");

Note: The mysql_real_escape_string function is valid only when the mysql database connection is successful.


Link to this article:

Add to favorites ^ please keep the tutorial address.

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.