手机
当前位置:查字典教程网 >编程开发 >php教程 >mysql_escape_string()函数用法分析
mysql_escape_string()函数用法分析
摘要:本文实例讲述了mysql_escape_string()函数用法。分享给大家供大家参考,具体如下:使用mysql_escape_string...

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

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

有一些数据例如:

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

如果这个时候,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);

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

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

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

【mysql_escape_string()函数用法分析】相关文章:

BBS(php & mysql)完整版(六)

php中smarty变量修饰用法实例分析

PHP 反射(Reflection)使用实例

PHP SplObjectStorage使用实例

BBS(php & mysql)完整版(一)

php使用array_search函数实现数组查找的方法

substr()函数中文版

Php+SqlServer实现分页显示

php计算给定时间之前的函数用法实例

php正则preg_replace_callback函数用法实例

精品推荐
分类导航