Stom Posted September 4, 2008 Share Posted September 4, 2008 Hello all, I'm using the PHP mail function to send the contents of an order form to both the end-user and the website owner. The script i have basically loops through the submitted items and adds to a string called $order: for ($x=1; $x<($_POST['element_count']+1); $x++) { if ($_POST['option'.$x.'qty']!=="na" && $_POST['option'.$x.'qty']!=="") { $order.= "<tr><td>".$x."</td><td>"; $prod = mysql_fetch_array(mysql_query("SELECT * FROM prod WHERE id = ".substr($_POST[$x.'_prod'],-3,3))); $cat = mysql_fetch_array(mysql_query("SELECT * FROM cat WHERE id = ".$prod['cat'])); $order.= $cat['name']."</td><td>".$prod['name']."</td><td>".$_POST['option'.$x.'qty']; $order.="</td></tr>"; } } This just generates a big list of items, the quantity and then i use the following to mail them off: $to = '[email protected]'; $subject = 'Website Order-form submission'; $message = $order; $headers = 'From: [email protected]' . "\n". 'Reply-To: [email protected]'. "\n". 'X-Mailer: PHP/' . phpversion() ."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n\n"; mail($to, $subject, $message, $headers); The $order string is also then written to the page so that the user can see on the website what they have ordered. The website version appears fine, but there's something going on with the emails that are sent out. for some random reason the emails are coming through with an exclamation mark and a space inserted at random intervals (eg "Fruit Bas! kets") although always in the same place. I've checked for any odd characters that have made their way into the database and there aren't any. This is driving me up the wall, does anyone have any suggestions? Many thanks in advance! Link to comment https://forums.phpfreaks.com/topic/122743-mail-function-inserting-random-characters/ Share on other sites More sharing options...
Stom Posted September 4, 2008 Author Share Posted September 4, 2008 *bump* any suggestions anyone? please? :-\ Link to comment https://forums.phpfreaks.com/topic/122743-mail-function-inserting-random-characters/#findComment-633965 Share on other sites More sharing options...
drisate Posted September 4, 2008 Share Posted September 4, 2008 it is caused by too many characters on one line. try using \n Link to comment https://forums.phpfreaks.com/topic/122743-mail-function-inserting-random-characters/#findComment-633969 Share on other sites More sharing options...
Stom Posted September 4, 2008 Author Share Posted September 4, 2008 Thank you for your reply drisate. Can you provide more information? The odd characters only seem to appear in the parts generated by the form. I will often get several in only a few words. The rest of email displays fine. Link to comment https://forums.phpfreaks.com/topic/122743-mail-function-inserting-random-characters/#findComment-633988 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.