aeroswat Posted January 11, 2010 Share Posted January 11, 2010 I am doing an e-mail and trying to add line feeds to my string before I send the e-mail so after each line I put the following . "\r\n" . It decides when it wants to work and when it doesn't. It flip flops the lines that don't get changed. Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/ Share on other sites More sharing options...
MadTechie Posted January 11, 2010 Share Posted January 11, 2010 define "flip flops the lines" also theirs nothing wrong with the code supplied, is the email text or html ? Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-992803 Share on other sites More sharing options...
aeroswat Posted January 11, 2010 Author Share Posted January 11, 2010 define "flip flops the lines" also theirs nothing wrong with the code supplied, is the email text or html ? I've noticed that when the previous line runs half the page the next line will jump up to the previous line instead of doing the line feed... Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-992808 Share on other sites More sharing options...
aeroswat Posted January 11, 2010 Author Share Posted January 11, 2010 define "flip flops the lines" also theirs nothing wrong with the code supplied, is the email text or html ? I've noticed that when the previous line runs half the page the next line will jump up to the previous line instead of doing the line feed... oh and it's text that is being e-mailed Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-992814 Share on other sites More sharing options...
MadTechie Posted January 11, 2010 Share Posted January 11, 2010 is the email text or html ? Do you have an example? Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-992817 Share on other sites More sharing options...
aeroswat Posted January 11, 2010 Author Share Posted January 11, 2010 is the email text or html ? Do you have an example? ORDER #: 1051 Authorizing Name: Omitted Phone #: (###)###-#### E-Mail: Omitted Student Name: Teacher School System: Baldwin County (here it's screwing up)Shipping School: Omitted School Shipping Attention: Omitted Shipping Address: Omitted City/State/Zip: Omitted Grade Level: OR --- Supply Order --- (Here it's screwing up)Item Name: Functiona Vision and Learning Media Assessment APH Number: 7-96151-00 Amount: 1 Additional Comments: Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-992825 Share on other sites More sharing options...
MadTechie Posted January 11, 2010 Share Posted January 11, 2010 When you have problems with an output, showing only the output hardly helps! is the email text or html ? Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-992873 Share on other sites More sharing options...
aeroswat Posted January 11, 2010 Author Share Posted January 11, 2010 When you have problems with an output, showing only the output hardly helps! is the email text or html ? I already said it was text and I gave the code i'm using... echo "\r\n" ... was wondering if there's something special about the line feed that would make it do that. I can post the exact code as it's written if you'd like but the other stuff doesn't seem as important <?php function addspace($str, $len){ if (strlen($str) >= $len){return $str;} return $str . str_repeat(" ", $len-strlen($str)); } $aps = $authArea . $authPhoneOne . $authPhoneTwo; $date = date('Y-m-d'); if($ordSupply=='1') { mysql_query("INSERT INTO tblOrders (StudentNumber, AuthorizingName, AuthorizingPhone, AuthorizingEmail, SchoolSystem, StudentGrade, SupplyName, SupplyAPH, SupplyAmt, FormatNeeded, OrderComment, ShipAttention, ShipAddress, ShipName, ShipCity, ShipZip, DateOrdered) VALUES ('$studentNumber', '$authName', '$aps', '$authEmail', '$ss', '$stuGrade', '$supName', '$supAPH', '$supAmt', 'Supply', '$bookComment', '$shipAttention', '$shipAddress', '$shipName', '$shipCity', '$shipZip', '$date')") or die("Unable to add order!"); } if($ordBook=='1') { mysql_query("INSERT INTO tblOrders (StudentNumber, AuthorizingName, AuthorizingPhone, AuthorizingEmail, SchoolSystem, StudentGrade, BookTitle, BookSubject, Copyright, ISBNten, Publisher, FormatNeeded, Compatible, YearNeeded, OrderComment, ShipAttention, ShipAddress, ShipName, ShipCity, ShipZip, DateOrdered) VALUES ('$studentNumber', '$authName', '$aps', '$authEmail', '$ss', '$stuGrade', '$bookTitle', '$bookSub', '$bookCopy', '$bookISBN', '$bookPub', '$bookFormat', '$bookAccept', '$bookSchool', '$bookComment', '$shipAttention', '$shipAddress', '$shipName', '$shipCity', '$shipZip', '$date')") or die("Unable to add order!"); } $qry = "SELECT OrderNumber FROM tblOrders ORDER BY OrderNumber DESC"; $result = mysql_query($qry) or die("No orders exist!"); $res = mysql_fetch_array($result); $to = "eragera@ergare.ert"; $subject = "Order for student #" . $studentNumber; $header = 'From: Orders@aidb.org' . "\r\n" . 'Reply-To: no-reply@aidb.org' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $message = addspace("",20) . "ORDER #: " . (($ordBook=='1' && $ordSupply=='1') ? ($res['OrderNumber']-1) . " and " . $res['OrderNumber'] : $res['OrderNumber']) . "\r\n" . 'Authorizing Name: ' . $authName . "\r\n" . 'Phone #: (' . $authArea . ")" . $authPhoneOne . "-" . $authPhoneTwo . "\r\n" . 'E-Mail: ' . $authEmail . "\r\n" . "\r\n" . 'Student Name: ' . $studentName . "\r\n" . 'School System: ' . $ss . "\r\n" . 'Shipping School: ' . $shipName . "\r\n" . 'Shipping Attention: ' . $shipAttention . "\r\n" . 'Shipping Address: ' . $shipAddress . "\r\n" . 'City/State/Zip: ' . $shipCity . ", AL " . $shipZip . "\r\n" . 'Grade Level: ' . $stuGrade . "\r\n" . "\r\n"; if($ordSupply == '1') { $message .= '--- Supply Order ---' . "\r\n" . 'Item Name: ' . $supName . "\r\n" . 'APH Number: ' . $supAPH . "\r\n" . 'Amount: ' . $supAmt . "\r\n\r\n"; } if($ordBook == '1') { $message .= '--- Book Order ---' . "\r\n" . 'Title: ' . $bookTitle . "\r\n" . 'Subject: ' . $bookSub . "\r\n" . 'Publisher: ' . $bookPub . "\r\n" . 'Copyright: ' . $bookCopy . "\r\n" . 'ISBN: ' . ($bookText=='1' ? $bookISBN : 'N/A') . "\r\n" . 'Format: ' . $bookFormat . "\r\n" . 'Will accept compatible?: ' . ($bookAccept=='1' ? 'Yes' : 'No') . "\r\n" . 'Year Needed: ' . $bookSchool . "\r\n"; } $message .='Additional Comments: ' . $bookComment; if(mail($to, $subject, $message, $header)) { echo "<h1 style='font-size:30;font-color:#00CD00;'><b>This form has been submitted...Order Successful!</b></h1>"; } else { echo "<h1 style='font-size:30;font-color:#CC1100;'><b>Registration Failed! Please contact <a href='reagergaer'>aergaergha</a></b></h1>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-993144 Share on other sites More sharing options...
MadTechie Posted January 12, 2010 Share Posted January 12, 2010 The reason i asked for an example was because the CR/NL works fine, and you refused to answer my question is the email text or html ? From your example it would seam that you have problems with the variables and not the CR/NL POC: change 'Item Name: ' . $supName . "\r\n" . to 'Item Name: ' . 'debug' . "\r\n" . and 'Shipping School: ' . $shipName . "\r\n" . to 'Shipping School: ' . 'debug'. "\r\n" . and check the formatting, if as i expect the formatting is find, then check the variables. Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-993546 Share on other sites More sharing options...
aeroswat Posted January 12, 2010 Author Share Posted January 12, 2010 Well better to ask this then... what could be placed in the variables that could cause the line feeds to be ignored? I know that there's an issue with the variables because of the fact that it only happens on some of them while others are formatted correctly. btw thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-993661 Share on other sites More sharing options...
MadTechie Posted January 12, 2010 Share Posted January 12, 2010 okay this would be over the top, but if it doesn't work then we're need to re-think the approach, /*CleanText will remove any character that is not a to z or 0 to 9 Eg, $supName=CleanText($supName);*/ function CleanText($str){ return preg_replace('/[^a-z0-9]/i', '', $str); } however i personally would analyze the string, for example echo debugText("testing"); function debugText($str){ $array = str_split($str,1); $debug = ""; foreach($array as $arr){ // & # (without the space) seams to display incorrectly in the code box! $debug .= '&'.'#'.ord($arr).";"; } return $debug; } this will display testing BUT if you view source your see testing now check to see if their is any extra characters for example If i enter testing then i would get testing Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-993675 Share on other sites More sharing options...
MadTechie Posted January 12, 2010 Share Posted January 12, 2010 Or you could use <BR /> and on a HTML email Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-993688 Share on other sites More sharing options...
aeroswat Posted January 12, 2010 Author Share Posted January 12, 2010 Or you could use <BR /> and on a HTML email Do I have to differentiate anything on the function to make it an html e-mail or just add the tags in there like it was an html email? Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-993816 Share on other sites More sharing options...
mikesta707 Posted January 12, 2010 Share Posted January 12, 2010 to send html emails, the content type header must be set $headers = "blah blah \r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-993819 Share on other sites More sharing options...
aeroswat Posted January 12, 2010 Author Share Posted January 12, 2010 to send html emails, the content type header must be set $headers = "blah blah \r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; ty will that however break my addspaces function though which adds blank spaces instead of the html non breaking space? Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-993824 Share on other sites More sharing options...
MadTechie Posted January 12, 2010 Share Posted January 12, 2010 Add function function addnbspace($str, $len){ if (strlen($str) >= $len){return $str;} return $str . str_repeat(" ", $len-strlen($str)); } and replace your addspace with addnbspace, BUT it maybe an idea to use a table instead Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-993843 Share on other sites More sharing options...
aeroswat Posted January 12, 2010 Author Share Posted January 12, 2010 So I added the following to my header 'Content-type: text/html; charset=iso-8859-1' . "\r\n" and the following to my message <html> <body> Some text<br /> Some more text<br /> </body> </html> and it doesn't evaluate it when I view it in outlook. I did some searching and could not find any place where it said html wasn't enabled on my outlook 2003. Is there something i'm not including? Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-993879 Share on other sites More sharing options...
mikesta707 Posted January 12, 2010 Share Posted January 12, 2010 can you post your full header statement? Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-993897 Share on other sites More sharing options...
aeroswat Posted January 13, 2010 Author Share Posted January 13, 2010 can you post your full header statement? $header = 'From: Orders@aidb.org' . "\r\n" . 'Reply-To: no-reply@aidb.org' . "\r\n" . 'X-Mailer: PHP/' . phpversion() . 'Content-type:text/html;charset=iso-8859-1' . "\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/188057-line-feed-decides-when-it-wants-to-work/#findComment-994215 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.