[英]Is mysql_real_escape_string necessary if there are no user inputs?
Do I have to use mysql_real_escape_string
for every query or just when there are user inputs on the page? 我是否必须为每个查询使用
mysql_real_escape_string
,或者只是在页面上有用户输入时?
Let's say I have: 比方说我有:
$check = mysql_query ("SELECT * FROM users WHERE user='$user' AND pm='$on'");
$numrows_check = mysql_num_rows($check);
if ($numrows_check == 1) {
Do I have to worry about SQL injections here if the page has no user inputs? 如果页面没有用户输入,我是否必须担心SQL注入?
PS I know pdo
and mysqli
, I'm asking specifically for mysql
. PS我知道
pdo
和mysqli
,我是专门针对mysql
。 Thanks. 谢谢。
SQL injection can be inject using form and also using links. SQL注入可以使用表单注入,也可以使用链接。 It means whenever there is input form the user then you have to you mysq_real_escape_string()
这意味着只要有用户的输入,那么你必须得到mysq_real_escape_string()
How injection can inject using link. 注射如何使用链接注入。 and example is given below.
以下给出了一些例子。
http:///www.mysite.com?delete.php?id=5
if URL like this is shown and some one can change this "5" to his/her desired value. 如果显示这样的URL,并且某些人可以将此“5”更改为他/她期望的值。 so there are several method to avoid this type of injection a simple solution is that you can use intval() .
所以有几种方法可以避免这种类型的注入,一个简单的解决方案是你可以使用intval() 。
so it is necessary to use all convention to each and every vulnerable point. 因此有必要对每个易受攻击的点使用所有约定。 so you can be safe form injection.
所以你可以安全注塑。 so Prevention is better than cure.
所以预防胜于治疗。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.