Jump to content

Recommended Posts

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...  :wtf:

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...  :wtf:

 

oh and it's text that is being e-mailed

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:

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>";
}
?>

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.

 

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!

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
&#116;&#101;&#115;&#116;&#105;&#110;&#103;

now check to see if their is any extra characters

for example

If i enter

testing
then i would get
&#116;&#101;&#115;&#116;&#105;&#110;&#103;&#1;

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?

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

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.