PHP 使用 PDO 语句清理输入

标签 php mysql pdo sanitization

<分区>

Possible Duplicate:
How to prevent SQL injection in PHP?

我使用 PDO 准备语句来防止 MySQL 注入(inject),但我是否应该做更多的事情来清理用户输入?将仅向用户显示他自己的输入和他“ friend ”的其他人的输入。我还需要做些什么来清理输入吗?

我不认为魔术引号已启用,而且我想不出任何其他方式可以让用户弄乱我的网站,但我是新手,所以我不确定。

提前致谢!

最佳答案

如果您使用准备好的语句,则 you shouldn't have any issue with MySQL injection .

If an application exclusively uses prepared statements, the developer can be sure that no SQL injection will occur (however, if other portions of the query are being built up with unescaped input, SQL injection is still possible).

您可能会考虑 sanitizing your output ,但是,就像只显示某些 HTML 标记(如果有的话)一样,以避免有人弄乱网站布局或更糟糕的是执行任意 JavaScript 的问题。

关于PHP 使用 PDO 语句清理输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14665651/

相关文章:

mysql - 连接表并根据值将同一列获取到更多列

php - Mysql用户崩溃的情况

php - 无法使用 "execute()"执行我的 PDO 查询,出现 "bindParam()"错误

php - 如何解决错误 "[ErrorException] file_get_contents(/var/www/laravel/.env): failed to open stream: No such file or directory"?

php - 查询仅返回 9 个期望值中的 7 个

javascript - 通过 Ajax 在 PHP 中保存来自 Javascript 的数据 URL

php - PDO 查询未显示结果

php - 亚马逊产品广告 API 新版本/关键字搜索

mysql - mysql 更新中数字字段的条件 if(DEFAULT)

mysql - 在Codeigniter中获取多个数组并插入数据库