Home > Backend Development > PHP Tutorial > mysql_escape_string() function usage analysis_php skills

mysql_escape_string() function usage analysis_php skills

WBOY
Release: 2016-05-16 19:53:55
Original
1675 people have browsed it

The example in this article describes the usage of the mysql_escape_string() function. Share it with everyone for your reference, the details are as follows:

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

There are some data such as:

char query(1024);
sprintf (query, "select * from my_tbl where name = '%s'",name);

Copy after login

If at this time, name contains data such as: "0'Malley,Brian", such a query statement will be generated: select * from my_tbl where name = '0'Malley,Brian', which will cause an error. of production.

The process of calling mysql_escape_string() is as follows:

my $item = "aaa's bbb"
my $escape_item = mysql_escape_string($item);

Copy after login

At this time, the content of escape_item is: aaa's bbb

PS: This function has been deprecated in PHP5.3, so you only need to know about this function and its use is not recommended.

Readers who are interested in more PHP-related content can check out the special topics of this site: "php programming security tutorial", "php security filtering skills summary", "Summary of PHP operations and operator usage", "Summary of PHP network programming skills", "PHP basic syntax introductory tutorial", "PHP operating office document skills Summary (including word, excel, access, ppt) ", "php object-oriented programming introductory tutorial ", "php string (string) usage summary ", " php mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will be helpful to everyone in PHP programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template