php - Right way to escape string after replacing quotes?
30
Is this the right way to escape a string just in case or I can insert string like this without additional escaping?
$filenamefordb = preg_replace('/[^A-Za-z0-9а-яА-Я_\.\-]/u', '', $filenamefordb);
$query = "INSERT INTO file SET filename='$filenamefordb";
I don't use mysqli_escape because I also need name without any quotes in another place
Answer
Solution:
Why don't you escape the string using PDO?
This will output
Reference: http://php.net/manual/it/pdo.quote.php
Answer
Solution:
you can escape it with a generic php function: