Page 1 of 1

Displaying pre-escaped varibles

Posted: Fri Feb 26, 2010 9:49 am
by marty pain
Just a quick one.

I'm displaying a users name on the screen after they log in. The name is escaped when it was saved to the database so, for example:

Steve 'the idiot' Austin is displayed as Steve \'the idiot\' Austin

Do I have to use str_replace() to swap '\' out, or can I read them in or display them in a way to sort it out?

Re: Displaying pre-escaped varibles

Posted: Fri Feb 26, 2010 9:58 am
by AbraCadaver
Use stripslashes(), however there are several possible reasons for your problem. Either magic_quotes_gpc() is enabled and then the data was manually escaped again before insert or magic_quotes_runtime() is enabled and the data is escaped when it comes out of the database. You should really turn of magic_quotes_* as it is deprecated and will be removed, plus it causes these sorts of problems.

Re: Displaying pre-escaped varibles

Posted: Fri Feb 26, 2010 11:05 am
by marty pain
Excellent. Thanks mate.

magic_quotes_gpc() was set on, so the string was being escaped twice.

Turned it off and re-entered the string and now it's all ok.

Thanks,
Steve