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.