可以仅使用addslashes(string)来防止SQL注入吗? [英] Can SQL injection be prevented with just addslashes(string)?

查看:145
本文介绍了可以仅使用addslashes(string)来防止SQL注入吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
mysql_real_escape_string()做什么而addslashes()不会做什么? t?

Possible Duplicate:
What does mysql_real_escape_string() do that addslashes() doesn't?

如果没有,我使用了mysql_escape_string,它在\ r \ n之类的单词中添加了字符,我不希望这样..

If not, I have used mysql_escape_string, and it adds characters to the words like \r\n, and I don't want that..

推荐答案

不,这不安全.请使用mysql_real_escape_string().它不应添加任何超出转义字符串所需的内容.

No, it's not safe. Use mysql_real_escape_string() instead. It shouldn't add anything beyond what it takes to escape the string.

http://php.net/mysql-real-escape-string

这也适用于其他数据库:使用扩展名专用的转义功能.

This applies to other databases too: use the extension-specific escape function.

这篇关于可以仅使用addslashes(string)来防止SQL注入吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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