使用MDB2防止PHP注入PHP

Luc*_*man 3 php postgresql sql-injection mdb2

我想弄清楚如何防止sqlinjection,我写了这个基本功能:function

antiInjectie($inputfromform){
    $temp = str_replace("'", "`",$inputfromform);
    $temp = str_replace("--", "~~",$temp);
    return htmlentitites($temp);
}
Run Code Online (Sandbox Code Playgroud)

然而有人告诉我也要考虑十六进制值,但我该怎么做?

更新 我坚持使用MDB2和pgsql

Que*_*tin 6

Bobby-Tables有一个很好的指导来防止SQL注入.

简而言之:不要自己扭曲输入,使用允许绑定参数的数据库API方法.