I am facing the reality of using mysqli vs. mysql. I have the following function that sanitize data
This is how the code was using mysql
function sanitize($data){
return htmlentities(strip_tags(mysql_real_escape_string($data)));
}
Error message when using mysql
Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in...
after reading php manual reference on https://www.php.net/mysqli_real_escape_string and made the changes below...
function sanitize($data){
return htmlentities(strip_tags(mysqli_real_escape_string($data, '0')));
}
...I receive the following Error message after using mysqli
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, string given in....
This is now preventing me from logging in. Any help is greatly appreciated!
mysqli $link , string $escapestrin the manual and change your code to$data, '0'? There're many examples if you can't understand the syntax of the manual.sanitize()but a more proper name would bemangle()orcorrupt(). If you read that in a tutorial I suggest you find another reference text—that code doesn't make any sense.