使用MDB2防止PHP中的SQL注入 [英] Preventing SQL injection in PHP with MDB2

查看:77
本文介绍了使用MDB2防止PHP中的SQL注入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图弄清楚如何防止sqlinjection,我写了这个基本函数:function

I'm trying to figure out how to prevent sqlinjection, I wrote this basic function : function

antiInjectie($inputfromform){
    $temp = str_replace("'", "`",$inputfromform);
    $temp = str_replace("--", "~~",$temp);
    return htmlentitites($temp);
}

但是有人告诉我也要考虑十六进制值,但是我该如何

However someone told me to also take hex values in consideration, but how do I do this?

更新
我被MDB2和pgsql困扰

Update I'm stuck with MDB2 and pgsql

推荐答案

Bobby-Tables 可以很好地防止SQL注入。

Bobby-Tables has a good guide to preventing SQL injection.

简而言之:不要自己打扰输入,请使用允许绑定参数的数据库API方法。

In short: Don't twiddle with the input yourself, use database API methods that allow bound parameters.

这篇关于使用MDB2防止PHP中的SQL注入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆