I don't have an answer to your question, but I can't pass by this thread with out pointing a few things out:
Do not use magic quotes!
It's good that your checking for it, but I strongly suggest having it turned off. It has even been removed from PHP 6 because of issues related to it.
Escape any data that goes into a database!
SQL injection can cripple a site, or worse yet, let a hacker sneak in quietly. Along with normal data verification, you should always use mysql_real_escape_string()
on any variables going into a query. INSERT, UPDATE, REPLACE, DELETE, and
SELECT. Always assume that no query is safe.