Home > php教程 > PHP源码 > php过滤sql注入关键词分析

php过滤sql注入关键词分析

WBOY
Release: 2016-06-08 17:27:05
Original
1385 people have browsed it

1.使用mysql_real_escape_string代替 addslashes对输入进行转义 2.字段值两边加上单引号

<script>ec(2);</script>

str_replace替换sql 中的 update 这种做法本身就是错误的, 原因如下:

如果sql中本来就有update字段,如以下的SQL

 代码如下 复制代码
$sql = "update content = 'update your name ..' where userid=1"

那么,你用str_replace替换的后果是什么? 只要用户提交的内容中包含有update,

delete, alter均被篡改?  这是多么可怕的事!!!

那么正确的办法是什么呢?

 代码如下 复制代码
$content = mysql教程_real_escape_string($content);
$sql = "update content = '$content' where userid=1
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template