简体   繁体   English

如果没有用户输入,是否需要mysql_real_escape_string?

[英]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我知道pdomysqli ,我是专门针对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.

相关问题 使用mysql_real_escape_string()作为用户输入是否安全? - Is it safe to use mysql_real_escape_string() for user inputs 是否有必要使用mysql_real_escape_string()将图像导入mysql? - Is it necessary to use mysql_real_escape_string() for image into mysql? 使用准备好的语句时是否需要 mysql_real_escape_string()? - Is mysql_real_escape_string() necessary when using prepared statements? mysql_real_escape_string()对于$ _SESSION变量是否必要? - mysql_real_escape_string() for $_SESSION variables necessary? mysql_real_escape_string和' - mysql_real_escape_string and ’ mysql_real_escape_string没有逃脱“ - mysql_real_escape_string does not escape " PHP:mysql_real_escape_string是否足以清除用户输入? - PHP: Is mysql_real_escape_string sufficient for cleaning user input? mysql_real_escape_string和用户'ODBC'@'localhost'的访问被拒绝 - mysql_real_escape_string and Access denied for user 'ODBC'@'localhost' mysql_real_escape_string 扭曲用户输入 - 如何修复 - mysql_real_escape_string distorts user input - how to fix 警告:mysql_real_escape_string()[function.mysql-real-escape-string]:拒绝用户访问 - Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM