by VenerableSage » Thu Feb 11, 2010 9:00 am
(Newbie ahoy, but I have knowledge of SQL and PHP.)
@Prinny, Solice, (robbie) - The reason for the additional backslashes is that the text is being reentered (or something akin to that) into the SQL field that it sits in. While in that text field, it keeps each apostrophe as \' (as was said), and when it's reentered, it needs to add the \\ in order to convert \' into something that its field can handle. So, as Solice said, it'll escape the backslash, making it a pair, and then escape the apostrophe, making it \'. Thus, you get an increased number of backslashes every time the text is reentered into the database.
-------------
Possible solution:
While I'm not personally seeing the escaped apostrophes on my end, if you put in calls to the PHP function stripslashes() in the sections where the (problematic) text will be displayed on the pages, it'll remove all instances of the backslashes from the text when it's displayed. Granted, this won't "solve" the problem of the backslashes being added when the comment is entered into the SQL database (to which, I'm unaware of a solution, as that's SQL's way of maintaining that character in the text block), but at least they won't appear when the text on the page is output.
(Also, as I came across it when I was working with a similar situation, sometimes the stripslashes() function won't remove all of the backslashes and will only catch some of them. In that case, you may need to write a recursive function that calls stripslashes() until there aren't any backslashes left.)
(As for that specific inconsistency, it's likely a PHP version difference, I would suspect. Either that, or just a matter of different configurations or something between the two servers. I experienced a similar issue of the summer with an application that I was working on. We ended up having to manually debug the software and fix things as we found them. :/)
Hopefully that's helpful in some way. (And, hopefully, I didn't make myself look stupid for either not answering anything of use or for posting a solution if it was fixed between yesterday and today. >_>)

Old work that I "made". Can't think of anything better to put here.