mysql_escape_string()函数用法分析,mysqlescapestring_PHP教程

WBOY
Release: 2016-07-12 08:53:29
Original
878 people have browsed it

mysql_escape_string()函数用法分析,mysqlescapestring

本文实例讲述了mysql_escape_string()函数用法。分享给大家供大家参考,具体如下:

使用 mysql_escape_string() 对查询中有疑问的数据进行编码:

有一些数据例如:

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

Copy after login

如果这个时候,name 中包含了如: "0'Malley,Brian" 这样的数据就会产生这样的查询语句: select * from my_tbl where name = '0'Malley,Brian' 这样就导致了错误的产生。

调用 mysql_escape_string() 的过程如下:

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

Copy after login

此时,escape_item 的内容是: aaa\'s bbb

PS:在PHP5.3中已经弃用该函数,因此仅对该函数有所了解即可,不推荐使用。

更多关于PHP相关内容感兴趣的读者可查看本站专题:《php程序设计安全教程》、《php安全过滤技巧总结》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php操作office文档技巧总结(包括word,excel,access,ppt)》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家PHP程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1123837.htmlTechArticlemysql_escape_string()函数用法分析,mysqlescapestring 本文实例讲述了mysql_escape_string()函数用法。分享给大家供大家参考,具体如下: 使用 mysql_e...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!