Problem with PHP mailing script

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
magosla2001
Forum Newbie
Posts: 20
Joined: Sat May 20, 2006 8:54 am

Problem with PHP mailing script

Post by magosla2001 »

I am having problem with my emails if characters like " ' are in the body of my message using the <textarea> tag for the message body. When my recipient recievs the email this is what happens, if I had a word like wasn't it becomes wasn\'t this problem occurs in both plain text and Html messages using the <textarea>. but if the mesage has already been defined in my php script for example
$messaeg = <<<ABC
Thi is a place wasn't bad the last time I visited
ABC;

I don't exprience the problem.
So I will like to know if any additional header could be added to my mailing script to help eradicate this problem in HTML and Plian text messages.
Last edited by magosla2001 on Sat May 20, 2006 10:41 am, edited 1 time in total.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

The problem you're experiencing is the fact that you (or your isp) has enabled magic_quotes... Ask them to disable it because it messes up your data (in a way that it shouldn't...)... Otherwise you can also 'undo' the mess (sample code can be found at http://www.nyphp.org/phundamentals/stor ... ieving.php)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

if (get_magic_quotes_gpc()) {
  $in = array(&$_GET, &$_POST, &$_COOKIE);
  while (list($k,$v) = each($in)) {
      foreach ($v as $key => $val) {
           if (!is_array($val)) {
                $in[$k][$key] = stripslashes($val);
                continue;
           }
           $in[] =& $in[$k][$key];
      }
  }
  unset($in);
}
Post Reply