1

For the last 4 years I've run a site mistakenly using both magic quotes and mysql_real_escape_string simultaneously.

This has resulted in all manner of different format strings being stored where in most cases quotes are doubly escaped and thus incorrectly shown when selected from the database.

I've know realized that having both on is incorrect and with the dropping of magic quotes in php6 will be turning that off asap.

The main question is are there any existing scripts/functions that exist to recover some of the incorrectly stored values within strings in a database?

It would then be possible to loop through all 'text' columns and replace these occurrences to what they should correctly be without having to manually go through thousands of rows.

I'd imagine with magic quotes support being dropped in the near future that there may be a need for such a script as users switch from one to the other?

Dan
  • 11,914
  • 14
  • 49
  • 112
  • 1
    PHP6 is off the table, 5.4 has displaced it. There were some scripts around PHP3 times when the current (evil) incarnation of magic_quotes was reintroduced and people also used double-escaping erroneously. Hard to find a generic solution now. You probably should write a custom script, and augment your database tables with a flag column (mq_fixed). Traverse DB and set flag. And it's probably guesswork still. You also need to consider that some entries have been updated, so backslashes quadrupled etc. – mario Dec 18 '11 at 05:48
  • 2
    Okay, well. This looks workable and less effort: http://dba.stackexchange.com/questions/2261/how-do-i-remove-backslashes-from-records-in-mysql – mario Dec 18 '11 at 05:51

0 Answers0