你的语句是什么? select * from xxx where id = ????? , 由???部分注入?
这个不用吧,反正就是希望运行select语句时不要被注入了比如 $sql="select * from user where username='abc' and password='123' "; $rs=$db->getRs($sql); if($rs) echo "登陆成功"; else echo "用户名或密码不对";被注入后 $sql="select * from user where username='abc' and password=' ' or 1=1 or ' ' "; 红色表示是用户输入的,这样就通过单引号被注入了
$sql="select * from user where username='abc' and password='123' ";
$rs=$db->getRs($sql);
if($rs)
echo "登陆成功";
else
echo "用户名或密码不对";被注入后
$sql="select * from user where username='abc' and password=' ' or 1=1 or ' ' ";
红色表示是用户输入的,这样就通过单引号被注入了
function filter($str) {
$str= str_replace("\\", "\\\\", $str);//反斜杠转义
$str= str_replace("'", "\'", $str);//单引号转义
return trim($str);//去除两边空格
}
这样就安全了嘛