Analysis of mysql_escape_string function usage

Source: Internet
Author: User
Tags php database php programming
This example describes the use of the mysql_escape_string () function. Share to everyone for your reference, as follows:

Use Mysql_escape_string () to encode the data in question in the query:

There are some data such as:

Char query (1024x768); sprintf (Query, "SELECT * from my_tbl where name = '%s '", name);

If this time, the name contains such as: "0 ' Malley,brian" such data will produce such a query statement: SELECT * from my_tbl where name = ' 0 ' Malley,brian ' This leads to the generation of errors.

The procedure for calling Mysql_escape_string () is as follows:

My $item = "AAA ' s BBB" my $escape _item = mysql_escape_string ($item);

At this point, the contents of the Escape_item are: aaa\ ' s BBB

PS: This function has been deprecated in PHP5.3, so it is not recommended to have an understanding of the function.

More about PHP related content readers can view the topic: "PHP Programming Security Tutorial", "PHP Security Filtering Skills Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP Basic Grammar Introductory Tutorial", " PHP's tips for working with Office documents (including WORD,EXCEL,ACCESS,PPT), PHP tutorial for object-oriented programming, PHP string usage Summary, PHP+MYSQL database operations Getting Started tutorial, and A summary of common PHP database operation techniques

I hope this article is helpful to you in PHP programming.

The above describes the Mysql_escape_string function usage analysis, including the string,escape aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Large-Scale Price Reduction
    • 59% Max. and 23% Avg.
    • Price Reduction for Core Products
    • Price Reduction in Multiple Regions
    undefined. /
    Connect with us on Discord
    • Secure, anonymous group chat without disturbance
    • Stay updated on campaigns, new products, and more
    • Support for all your questions
    undefined. /
    Free Tier
    • Start free from ECS to Big Data
    • Get Started in 3 Simple Steps
    • Try ECS t5 1C1G
    undefined. /

    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.