may i always do
SET NAMES 'utf8'
to mysql connection (so I need multibyte screens).
Is there a safe alternative to mysql_real_escape_string that does not need mysql connection?
On the official page, I found a comment that uses str_replace as follows:
if(!empty($inp) && is_string($inp)) { return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z') , $inp); }
enough?
And why does mysql_real_escape_string need the current charcaterset if it only avoids the same values? (as described on the official php.net/mysql_real_escape_string page)
thanks
source share