i wanted to protect my website from sql injections and other possible risks, so i changed all my sql queries by adding for each variable something like this :
$getLid = htmlspecialchars($_GET[lid], ENT_QUOTES);
For my 50 files... But i have just seen that it might be my mistake : i should have added mysql_real_escape_string for any "input"...
Is it still better to use mysql_real_escape_string
in this case, or the ENT_QUOTES
works also? Do i have to restart again and add mysql_real_escape_string
instead of my htmlspecialchars(..., ENT_QUOTES);
?
Edit :
Do you mean something like that?
$getLid = escape_string($str);
function escape_string($str){
return mysql_real_escape_string($str);
}
Edit n°2 : the return statement does not work properly, would you know why?
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in … www/escape_file.php
Access denied for user in … www/escape_file.php
Thanks