因为单引号已经被我转义了,那这样mysql是不是就安全 了呢

解决方案 »

  1.   

    你的语句是什么? select * from xxx where id = ????? , 由???部分注入?
      

  2.   

    这个不用吧,反正就是希望运行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 ' ' ";
    红色表示是用户输入的,这样就通过单引号被注入了
      

  3.   


    function filter($str) {
        $str= str_replace("\\", "\\\\", $str);//反斜杠转义
        $str= str_replace("'", "\'", $str);//单引号转义
        return trim($str);//去除两边空格
    }
    这样就安全了嘛