dongliyan7318 2010-09-24 01:31
浏览 25
已采纳

使用PDO清理变量

When using PDO, do i still need to addslashes or is this done already with PDO?

If it's already done, then do is there any other sanitizing i should do before inserting data to a table?

  • 写回答

1条回答 默认 最新

  • dougan7523 2010-09-24 01:33
    关注

    No, you definitely do not need addslashes if you're using PDOStatement properly. You don't need additional sanitization to prevent SQL injection. However, you may still want to validate in other ways. For example, you might check that an email field "looked like" an email address, or make sure that a plain text field did not contain certain characters. Finally, you may have to escape (e.g. with htmlspecialchars) when you output text from the database.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?