views:

58

answers:

3

I am working on a post type form. The site is wordpress based. While testing the form, I noticed that everytime I use the ''' character, when the post is posted, it prints out "\'" instead.

For example:

Input: "Bob's birthday plans." Output: "Bob\'s birthday plans."

How do I stop php or wordpress, whichever is responisble, from doing this?

+1  A: 

Could be magic_quotes_gpc or even worse magic_quotes_runtime.

This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.
[...]
When magic_quotes are on, all ' (single-quote), " (double quote), \ (backslash) and NUL's are escaped with a backslash automatically.
VolkerK
+2  A: 

Those are Magic Quotes, one of the most controversial features of PHP.

It is an option in PHP.ini, you should contact your hosting service and have them shut it off (Or look for the option yourself, if you are privileged enough to).

Jeffrey Aylesworth
+1  A: 

There seems to be a problem with magicquotes and according to this site, the fix consists in adding the following lines to your theme file:

if ( get_magic_quotes_gpc() ) {
    $_POST      = array_map( 'stripslashes_deep', $_POST );
    $_GET       = array_map( 'stripslashes_deep', $_GET );
    $_COOKIE    = array_map( 'stripslashes_deep', $_COOKIE );
    $_REQUEST   = array_map( 'stripslashes_deep', $_REQUEST );
}

Which would translate to something like, if magic quotes are enabled, remove the slashes from those variable arrays. Therefore fixing your issue.

johnnyArt