Unfortunately your "solution" will replace one type of data corruption (backslashes being spuriously inserted) with another (backslashes being spuriously removed).
I recommend this solution
if (ini_get('magic_quotes_gpc')) {
print "Turn stupid magic quotes off"; exit;
}
Magic quotes are always wrong, don't use them, don't assume they're turned on or off, just have your application politely quit if they're on.
Mark