The usual way to navigate sites with magic_quotes_gpc is to add a wrapper function:
function m($s) { if (get_magic_quotes_gpc()) $s= stripslashes($s); return mysql_real_escape_string($s); } mysql_query("SELECT * FROM foo WHERE bar='".m($_GET['baz'])."'");
This will fix the addslashes problem, which is not supportive, which could lead to its vulnerability in some cases and, as a rule, will cause the code to continue to work as before.
However, in the long run, relying on input-escaping is unstable because it will multiply slashes by input strings that you do not insert into the database, and cannot escape the lines that you insert into the database from other sources. This is the real reason magic_quotes_gpc is wrong: it applies the encoding of the output stage to the input frame.
So, add a wrapper function and then slowly update all SQL interpolations to use it. When you have everything, you can turn off magic quotes.
source share