Page 1 of 1

Problem with PHP mailing script

Posted: Sat May 20, 2006 10:23 am
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.

Posted: Sat May 20, 2006 10:29 am
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)

Posted: Sat May 20, 2006 1:19 pm
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);
}