I'm fairly new on PHP.
I'm trying to sanitize my input before UPDATE it on myqsql.
If my string is something with apostrophe, like " I'm new on Php" it not works with this code
$description = $_POST['description'];
$description = htmlspecialchars($description);
$description = mysqli_real_escape_string($description);
$description = trim(preg_replace('/\s+/', ' ', $description));
It didn't work: my field in table result empty
If i use
$description = $_POST['description'];
$description = htmlspecialchars($description);
$description = str_replace("'","\'", $description);
$description = trim(preg_replace('/\s+/', ' ', $description));
It works.
Why $description = mysqli_real_escape_string($description)
won't work ?