This article mainly introduces the usage of the mysql_escape_string () function, describes the functions of the mysql_escape_string () function based on the instance form, and analyzes the usage tips and precautions of the mysql_escape_string function, for more information about mysql_escape_string (), see the following example. We will share this with you for your reference. The details are as follows:
Use mysql_escape_string () to encode the data in question:
Some data, such:
Char query (1024); sprintf (query, "select * from my_tbl where name = '% s'", name );
If the name contains data such as "0 'Malley, Brian", a query statement is generated: select * from my_tbl where name = '0' Malley, brian.
The process of calling mysql_escape_string () is as follows:
My $ item = "aaa's bbb" my $ escape_item = mysql_escape_string ($ item );
In this case, the content of escape_item is aaa \'s bbb.
PS: This function has been deprecated in PHP5.3. Therefore, you only need to know about this function. it is not recommended.