I have a website which uses a custom function for addslashes on all mysql queries like this:
function custom_addslashes($str) {
return mysql_real_escape_string($str);
}
Recently I found out mysql_real_escape_string is deprecated. I have two options. Either
go through the entire site and convert to prepared statements for every page, (argh) or
modify the above function. I assume it is impossible to modify the above function to use PDO, since it is used for many different queries.
Is there a good way to do option 2. something like?
function custom_addslashes($str) {
return strtr($str, array("\0" => "", "\\" => "\","'","\\'"));
}
clarifed the question