/    Sign up×
Community /Pin to ProfileBookmark

25th item in list has weird effect.

I have a page where people can order literature by filing a form. When they clcik submit it goes through the following PHP code:

<?php
$items = array(“Environmentally Sustainable Products”, “Green Circle Flyer”, “Green Action Initiative”, “Hurricane 670 XTT Spec Sheet”, “Hurricane 500 XTT Spec Sheet”, “Hurricane 600 XTT Spec Sheet”, “Professional Power Nozzles Spec Sheet”, “Propane High-Speed Burnisher Spec Sheet”, “Enviro Vac Spec Sheet”, “Blu-Lite Plus Feature Sheet”, “Film Away Feature Sheet”, “Power Lift Feature Sheet”, “Foundation Feature Sheet”, “Tradition Plus Feature Sheet”, “Soap Dispensers Spec Sheet”, “Eastern Chemical Price Book”, “Western Chemical Price Book”, “Equipment Agent Price Book”, “Equipment Distributor Price Book”, “Equipment SSP Price Book”, “MSDS Book”, “Parts Lists Book”, “Equipment Spec Sheet Booklet”, “Dustbane Catalogue”, “Info CD”, “Dustbane Sustainability Action Plan”, “Sanitation Programs”, “Since 1908 Presentation”, “WHMIS Overview”, “Dustbane Dilution Chart”, “Food Industry Wall Chart”, “Floor Care Chart”, “Carpet Care Chart”, “Washroom Care Chart”, “Hand Washing Chart”);
$values = array($enviro_products, $trifold, $green_action, $hurricane_670, $hurricane_500, $hurricane_600, $power_nozzles, $propane_burnisher, $envirovac, $blulite_plus, $film_away, $power_lift, $foundation, $tradition_plus, $soap_dispensers, $east_chem, $west_chem, $equip_agent, $equip_dist, $equip_ssp, $msds, $parts_lists, $equip_spec, $catalogue, $infoCD, $green_trends, $sanitation_programs, $since1908, $whmis, $dilution_chart, $food_chart, $floor_chart, $carpet_chart, $washroom_chart, $handwash_chart);

foreach($items as $key => $item)
if($values[$key] > 0)
$message .= $item . ‘: ‘ . ‘<b>’ . $values[$key] . ‘</b><br>’;
mail( “[email protected]“, “Literature Request – $name”, ‘<font face=”arial” size=”2″>’ . $message . ‘<p>’ . ‘<b>Note:</b><br>’ . $note . ‘<p>’ . $name, “From: $emailnContent-Type: text/html; charset=iso-8859-1” );
header( “Location: http://www.dustbane.ca/thanks_en.html” );
?>

It works for the most part, but I tested it ordering each and every item from that list and when I receive the request by email everything below item 24 (Dustbane Catalogues) is in bold.

I tried another test where I ordered 0 “MSDS Books” to see if everything below item 24 (Dustbane Catalogue becomes 23 since there are no MSDS Books, so the Info CD is 24 now). Everything below was NOT in bold, however, the 25th item is now “Dustbane Sustainability Action Plan” and for some reason, when I receive the email it is spelled “Dust! bane Sustainability Action Plan”.

What the heck is going on?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@temp_user123Jun 29.2007 — First, is the problem in the submission or in the sending of the email? So... Is your form submitted via POST? ...or, via GET?
Copy linkTweet thisAlerts:
@dover19authorJun 29.2007 — It's submitted via POST
Copy linkTweet thisAlerts:
@temp_user123Jun 29.2007 — OK, so probably not a submission problem. I think the problem is that you're not inserting line feeds into your message string -- but are sending it as one continuous string. Therefore, the email client is having to force a line break and, if this line break falls at an inopportune place in the string, can cause problems. So, the solution is to insert line feeds everywhere you're also inserting the HTML line break tag.
Copy linkTweet thisAlerts:
@dover19authorJun 29.2007 — Ok, so here's what I did:

<?php

$items = array("Environmentally Sustainable Products", "Green Circle Flyer", "Green Action Initiative", "Hurricane 670 XTT Spec Sheet", "Hurricane 500 XTT Spec Sheet", "Hurricane 600 XTT Spec Sheet", "Professional Power Nozzles Spec Sheet", "Propane High-Speed Burnisher Spec Sheet", "Enviro Vac Spec Sheet", "Blu-Lite Plus Feature Sheet", "Film Away Feature Sheet", "Power Lift Feature Sheet", "Foundation Feature Sheet", "Tradition Plus Feature Sheet", "Soap Dispensers Spec Sheet", "Eastern Chemical Price Book", "Western Chemical Price Book", "Equipment Agent Price Book", "Equipment Distributor Price Book", "Equipment SSP Price Book", "MSDS Book", "Parts Lists Book", "Equipment Spec Sheet Booklet", "Dustbane Catalogue", "Info CD", "Dustbane Sustainability Action Plan", "Sanitation Programs", "Since 1908 Presentation", "WHMIS Overview", "Dustbane Dilution Chart", "Food Industry Wall Chart", "Floor Care Chart", "Carpet Care Chart", "Washroom Care Chart", "Hand Washing Chart");

$values = array($enviro_products, $trifold, $green_action, $hurricane_670, $hurricane_500, $hurricane_600, $power_nozzles, $propane_burnisher, $envirovac, $blulite_plus, $film_away, $power_lift, $foundation, $tradition_plus, $soap_dispensers, $east_chem, $west_chem, $equip_agent, $equip_dist, $equip_ssp, $msds, $parts_lists, $equip_spec, $catalogue, $infoCD, $green_trends, $sanitation_programs, $since1908, $whmis, $dilution_chart, $food_chart, $floor_chart, $carpet_chart, $washroom_chart, $handwash_chart);

foreach($items as $key => $item)

if($values[$key] > 0)

$message .= $item . ': ' . '<b>' . $values[$key] . '</b><br>/n';

mail( "[email protected]", "Literature Request - $name", '<font face="arial" size="2">' . $message . '<p>' . '<b>Note:</b><br>/n' . $note . '<p>' . $name, "From: $emailnContent-Type: text/html; charset=iso-8859-1" );

header( "Location: http://www.dustbane.ca/thanks_en.html" );

?>

Now, it does the trick, but look at what happens to the email now:

Environmentally Sustainable Products: 1

/nGreen Circle Flyer: 2

/nGreen Action Initiative: 3

/nHurricane 670 XTT Spec Sheet: 4

/nHurricane 500 XTT Spec Sheet: 5

/nHurricane 600 XTT Spec Sheet: 6

/nProfessional Power Nozzles Spec Sheet: 7

/nPropane High-Speed Burnisher Spec Sheet: 8

/nEnviro Vac Spec Sheet: 9

/nBlu-Lite Plus Feature Sheet: 10

/nFilm Away Feature Sheet: 11

/nPower Lift Feature Sheet: 12

/nFoundation Feature Sheet: 13

/nTradition Plus Feature Sheet: 14

/nSoap Dispensers Spec Sheet: 15

/nEastern Chemical Price Book: 16

/nWestern Chemical Price Book: 17

/nEquipment Agent Price Book: 18

/nEquipment Distributor Price Book: 19

/nEquipment SSP Price Book: 20

/nMSDS Book: 21

/nParts Lists Book: 22

/nEquipment Spec Sheet Book! let: 23

/nDustbane Catalogue: 24

/nInfo CD: 25

/nDustbane Sustainability Action Plan: 26

/nSanitation Programs: 27

/nSince 1908 Presentation: 28

/nWHMIS Overview: 29

/nDustbane Dilution Chart: 30

/nFood Industry Wall Chart: 31

/nFloor Care Chart: 32

/nCarpet Care Chart: 33

/nWashroom Care Chart: 34

/nHand Washing Chart: 35

/n

Note:

/nShip today!

Eric
Copy linkTweet thisAlerts:
@dover19authorJun 29.2007 — OOPS! I got it to work now. Here's my new code:

<?php

$items = array("Environmentally Sustainable Products", "Green Circle Flyer", "Green Action Initiative", "Hurricane 670 XTT Spec Sheet", "Hurricane 500 XTT Spec Sheet", "Hurricane 600 XTT Spec Sheet", "Professional Power Nozzles Spec Sheet", "Propane High-Speed Burnisher Spec Sheet", "Enviro Vac Spec Sheet", "Blu-Lite Plus Feature Sheet", "Film Away Feature Sheet", "Power Lift Feature Sheet", "Foundation Feature Sheet", "Tradition Plus Feature Sheet", "Soap Dispensers Spec Sheet", "Eastern Chemical Price Book", "Western Chemical Price Book", "Equipment Agent Price Book", "Equipment Distributor Price Book", "Equipment SSP Price Book", "MSDS Book", "Parts Lists Book", "Equipment Spec Sheet Booklet", "Dustbane Catalogue", "Info CD", "Dustbane Sustainability Action Plan", "Sanitation Programs", "Since 1908 Presentation", "WHMIS Overview", "Dustbane Dilution Chart", "Food Industry Wall Chart", "Floor Care Chart", "Carpet Care Chart", "Washroom Care Chart", "Hand Washing Chart");

$values = array($enviro_products, $trifold, $green_action, $hurricane_670, $hurricane_500, $hurricane_600, $power_nozzles, $propane_burnisher, $envirovac, $blulite_plus, $film_away, $power_lift, $foundation, $tradition_plus, $soap_dispensers, $east_chem, $west_chem, $equip_agent, $equip_dist, $equip_ssp, $msds, $parts_lists, $equip_spec, $catalogue, $infoCD, $green_trends, $sanitation_programs, $since1908, $whmis, $dilution_chart, $food_chart, $floor_chart, $carpet_chart, $washroom_chart, $handwash_chart);

foreach($items as $key => $item)

if($values[$key] > 0)

$message .= $item . ': ' . '<b>' . $values[$key] . '</b><br>' . "n";

mail( "[email protected]", "Literature Request - $name", '<font face="arial" size="2">' . $message . '<p>' . '<b>Note:</b><br>' . "n" . $note . '<p>' . $name, "From: $emailnContent-Type: text/html; charset=iso-8859-1" );

header( "Location: http://www.dustbane.ca/thanks_en.html" );

?>

Thanks for the help
Copy linkTweet thisAlerts:
@temp_user123Jun 29.2007 — Yep, just a *little*, "Oops!" ;-)
×

Success!

Help @dover19 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 11.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @bahaedd,
tipped: article
amount: 1000 SATS,

tipper: @Balmasexy,
tipped: article
amount: 1000 SATS,

tipper: @mbsaad,
tipped: article
amount: 1000 SATS,
)...