可能重复:
如何防止 SQL 注入?
这是我清理我将要放入数据库的内容的尝试
$pictureID = $_REQUEST['pictureID'];
$userID = $_REQUEST['userID'];
$username = $_REQUEST['username'];
//Sanatize //Protext against injection
$username = filter_var($username, FILTER_SANITIZE_EMAIL);
$userID = filter_var($userID, FILTER_SANITIZE_STRING);
$pictureID = filter_var($pictureID, FILTER_SANITIZE_STRING);
$username = stripslashes($username);
$username = mysql_real_escape_string($username);
$userID = stripslashes($userID);
$userID = mysql_real_escape_string($userID);
$pictureID = stripslashes($pictureID);
$pictureID = mysql_real_escape_string($pictureID);
我有两个问题,以上就够了吗?
另外,如果我什么都不做echo $pictureID
,但是,如果我删除$pictureID = mysql_real_escape_string($pictureID);
thenecho $pictureID
作品。
这是正确的行为吗?