Getting rid of \' when sending mail

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
VKX
Forum Commoner
Posts: 41
Joined: Mon Oct 03, 2005 1:43 pm

Getting rid of \' when sending mail

Post by VKX »

When I send mail using the form on my site, all the ' marks have \ marks right before them. For instance, if I send

It was Eric's birthday

using my webform, I'll get an email saying

It was Eric\'s birthday

How can I get rid of that \ ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

this is something that I use regularly.

Code: Select all

if (get_magic_quotes_gpc() ) 
{ 
   $fnStripMagicQuotes = create_function('&$mData, $fnSelf', 
       'if (is_array($mData)) foreach ($mData as $mKey=>$mValue) $fnSelf($mData[$mKey], $fnSelf); '.
       'else $mData = stripslashes($mData);');
   $fnStripMagicQuotes($_POST,$fnStripMagicQuotes);
   $fnStripMagicQuotes($_GET,$fnStripMagicQuotes);
   $fnStripMagicQuotes($_COOKIE,$fnStripMagicQuotes);
   $fnStripMagicQuotes($_SERVER,$fnStripMagicQuotes);
} // end if

if (get_magic_quotes_runtime())
{
  set_magic_quotes_runtime(0);
}
Post Reply