I have tried every solution posted on other questions about this topic, but none of them work.
I\'m sorry if this is a basic question, but I\'m new
Currently, $connect
is out of scope, just add it in the parameter:
$connect = new mysqli('localhost', 'shop', 'password', 'zen');
function cleanInput($connect, $string = '') {
if(!empty($string)) {
$stripsql = $connect->real_escape_string($string);
return $stripsql;
}
}
$my_string = 'your string here';
$escaped_string = cleanInput($connect, $my_string);
Sidenote: Or if you can, you can also use prepared statements.