PHP 4 to 5 Magic Quote Fix?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mistymorningglory
Forum Newbie
Posts: 5
Joined: Fri Sep 26, 2008 4:27 pm

PHP 4 to 5 Magic Quote Fix?

Post by mistymorningglory »

Hi there, one of my clients has a CMS that was hosted on a php4.3 server
They fired their web developers, hired me, and moved to a new hosting environment that is php5 (I have no control over where they choose to host)

The original developers used magic quotes... Ugg

When the site was moved, I turned magic quotes on because of the HUGE volume of database inserts, updates and reads that were not coded with add/strip slashes.

Now, whenever they update any content, extra single quotes are being added everywhere.

I know the best thing to do is clean up the code with addslashes and stipslashes everywhere, but my client doesn't have the funding for that major of a re-write. (Literally thousands of occurrences need to be updated)

Does anyone have a less time-consuming workaround for this issue?

Thanks!
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: PHP 4 to 5 Magic Quote Fix?

Post by yacahuma »

Did you look at this
http://us.php.net/magic_quotes
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: PHP 4 to 5 Magic Quote Fix?

Post by jmut »

Ok, I don't get...didn't they have those extra single quotes (I think you mean slashes?) before as well. From what you wrote I understand you turned magic quotes on as was all before. If all acts like before...seems manager likes it that way.
mistymorningglory
Forum Newbie
Posts: 5
Joined: Fri Sep 26, 2008 4:27 pm

Re: PHP 4 to 5 Magic Quote Fix?

Post by mistymorningglory »

Yes, I've read all about magic quotes. The original codebase was poorly written and relys completely on it, so I turned it on in the new hosting environment (php5). Now when they update their content, extra single quotes are getting added.

For example, in a text field a customer enters their last name as "O'Malley".
Then if they do anything else where they update their profile, another single quote gets added, i.e. "O''Malley", then the next time they update, another one appears "O'''Malley", and so on...

It doesn't do this in PHP4.3 and I haven't been able to find any other posts where people are experiencing the same issue.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: PHP 4 to 5 Magic Quote Fix?

Post by jmut »

Well I don't think this is addslashes magic quotes issue. If it is..it should add '\' escape char not quotes.
mistymorningglory
Forum Newbie
Posts: 5
Joined: Fri Sep 26, 2008 4:27 pm

Re: PHP 4 to 5 Magic Quote Fix?

Post by mistymorningglory »

At one point I was thinking the same thing, but I couldn't figure out what else it would be.
Any ideas? It is certainally related to a difference between php4 & 5... Does php5 has something wokny about single quotes I haven't heard about?
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: PHP 4 to 5 Magic Quote Fix?

Post by jmut »

no clue. haven't heard of such thingy. I suggest you debug it and see what exactly cause it. If you figure it out for one case, should be same for rest.
Post Reply