let's consider i will always do a
SET NAMES 'utf8'
to mysql connection (so I need multibyte escapes).
Is there a safe alternative to mysql_real_escape_string that doesnt' need a mysql connection?
In the official page i found a comment that uses str_replace like this:
if(!empty($inp) && is_string($inp)) {
return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"),
array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z') , $inp);
}
is this enough?
And why mysql_real_escape_string needs the current charcaterset if it will only escape the same values? (as described in the official page php.net/mysql_real_escape_string)
thanks