Help with mail() array syntax.
Posted: Fri Dec 14, 2007 7:24 am
Hope someone can help here... probably a simple fix but just cant see it...
I'm sending an order confirmation email populated with data posted back from paypal payment standard. All $_POST data is received for all items purchased.. eg item 1, 2, 3 4... etc... when I list these items in the email... like this...
$orderemailcontent .= "$item_number1 - $item_name1 - $quantity1 - $mc_gross_1 \n";
The correct values are pulled and displayed in the email...
However, when I try to use a 'while' loop I do not get the same data.
Here's the code......................
Here's the result of the email..................
Item Number EG 1: t
t.
Item Number EG 2: $item_number[1]
$item_number[1].
Item Number EG 3: t
Item Number EG 4: t
Item Number EG 5: it2m_number21
Item Number EG 6: t
Item Number EG 7: i
Item Number EG 8: t
40 - cataloguenumber-artist-title-label- qty- 11.49
28 - cataloguenumber-artist-title-label- qty- 11.49
Item Number EG 1: 2
2.
Item Number EG 2: $item_number[2]
$item_number[2].
Item Number EG 3: 2
Item Number EG 4: t
Item Number EG 5: it2m_number22
Item Number EG 6: t
Item Number EG 7: i
Item Number EG 8: 2
40 - cataloguenumber-artist-title-label- qty- 11.49
28 - cataloguenumber-artist-title-label- qty- 11.49
Can anyone point me in the right direction as to the syntax I need to use for the while loop.. and shed some light on the reason for the results that are produced in the email..eg. No 5 where 'item' is relaced with 'it2m', dont get that one at all or the 't' or 'i'???
Thanks
Rich
I'm sending an order confirmation email populated with data posted back from paypal payment standard. All $_POST data is received for all items purchased.. eg item 1, 2, 3 4... etc... when I list these items in the email... like this...
$orderemailcontent .= "$item_number1 - $item_name1 - $quantity1 - $mc_gross_1 \n";
The correct values are pulled and displayed in the email...
However, when I try to use a 'while' loop I do not get the same data.
Here's the code......................
Code: Select all
$orderemail = "me@myemail.co.uk";
$ordersubject = "Order confirmation";
$orderheaders = "From: you@youremail.com\n";
$orderheaders . "MIME-Version: 1.0\n"
. "Content-Transfer-Encoding: 7bit\n"
. "Content-type: text/html; charset = \"iso-8859-1\";\n\n";
$orderemailcontent = "emailtext....";
$count = 1;
while ($count <= $num_cart_items){
//the following two lines pull the correct informatioin from $_POST data
$orderemailcontent .= "$item_number1 - $item_name1 - $quantity1 - $mc_gross_1 \n";
$orderemailcontent .= "$item_number2 - $item_name2 - $quantity2 - $mc_gross_2 \n";
//test variations of syntatax using $count.....for variable $item_number[$count] none of which work...
$orderemailcontent .= "Item Number EG 1: $item_number[$count] \n";
$orderemailcontent .= "$item_number[$count]. \n";
$orderemailcontent .= "Item Number EG 2: \$item_number[$count] \n";
$orderemailcontent .= "\$item_number[$count]. \n";
$orderemailcontent .= "Item Number EG 3: ".$item_number[$count]." \n";
$orderemailcontent .= "Item Number EG 4: ".$item_number[1]." \n";
$orderemailcontent .= "Item Number EG 5: ".$item_number.$count." \n";
$orderemailcontent .= "Item Number EG 6: ".$item_number['1']." \n";
$orderemailcontent .= "Item Number EG 7: ".$item_number['$count']." \n";
$orderemailcontent .= "Item Number EG 8: ".$item_number["$count"]." \n";
$orderemailcontent .= " \n\n";
$count=$count+1;
}
$orderemailcontent .= "end email ext";
mail($orderemail, $ordersubject, $orderemailcontent, $orderheaders);Here's the result of the email..................
Item Number EG 1: t
t.
Item Number EG 2: $item_number[1]
$item_number[1].
Item Number EG 3: t
Item Number EG 4: t
Item Number EG 5: it2m_number21
Item Number EG 6: t
Item Number EG 7: i
Item Number EG 8: t
40 - cataloguenumber-artist-title-label- qty- 11.49
28 - cataloguenumber-artist-title-label- qty- 11.49
Item Number EG 1: 2
2.
Item Number EG 2: $item_number[2]
$item_number[2].
Item Number EG 3: 2
Item Number EG 4: t
Item Number EG 5: it2m_number22
Item Number EG 6: t
Item Number EG 7: i
Item Number EG 8: 2
40 - cataloguenumber-artist-title-label- qty- 11.49
28 - cataloguenumber-artist-title-label- qty- 11.49
Can anyone point me in the right direction as to the syntax I need to use for the while loop.. and shed some light on the reason for the results that are produced in the email..eg. No 5 where 'item' is relaced with 'it2m', dont get that one at all or the 't' or 'i'???
Thanks
Rich