Jump to content

[SOLVED] handling single quotes within variable


coderb

Recommended Posts

Hi,

Can someone please tell me how to handle a string value containing a single quote when used in dynamically built html.

 

I have a form that posts back to itself. An input text field which first gets it's value from the database, containing string : haven't

this string is displayed correctly the first time, but when I post back the page to itself and repopulate the input text string with its $_POST value, the displayed string is now : haven\'t

 

why is the backslash inserted before the quote?

how should I handle this?

 

thanks,

thanks for the quick responses.

 

initially tried the htmlentities, but didn't do the trick, I think the Magic Quotes seems to be reason.

 

however, the the Magic Quotes link you inlcuded mentions a Warning - This feature is DEPRECATED and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.

 

So with this in mind should I just switch off magic_quotes_gpc or still use the stripslashes function?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.