Web Hosting Talk







View Full Version : re: php email prob


mjfroggy
01-11-2005, 07:06 PM
Hello,

I am having an error that I can not find where the issue is.

The error message I am getting looks like this
Parse error: parse error, unexpected T_DO in /home/****/*****/spinmaster/processorder.php on line 40

$body = Spinmaster." ".Entertainment." ".Order." ".Form."\n".PERSONAL." ".INFORMATION."\n".Firstname." ".$firstname." ".Lastname." ".$lastname."\n".Address." ".$address." ".City." ".$city."\n".State." ".$state." ".Zipcode." ".$zip."\n".Daytime." ".Phone." ".$dphone." ".Evening." ".Phone." ".$evephone."\n".Email." ".Address." ".$email."\n".PARTY." ".INFORMATION."\n".Type." ".of." ".occasion." ".$Occasion." ".Event." ".Date." ".$eventdate." ".Rain." ".Date." ".$raindate."\n".Time." ".event." ".starts." ".$eventstarttime." ".End." ".Time." ".$eventendtime."\n".Will." ".their." ".be." ".a." ".cocktail." ".hour." ".$cocktailhour."\n".Recipients." ".name." ".$Recipientname."\n".Will." ".their." ".be." ".adults." ".only." ".$adultsonly." ".How." ".many." ".adults." ".do." ".you." ".expect." ".$numberofadults."\n".Is."
".this." ".a." ".childrens." ".party." ".$kidsparty." ".How." ".many." ".children." ".do." ".you." ".expect." ".$numberofkids."\n".Are." ".you." ".going." ".to." ".have." ".mixed." ".guests." ".$mixedguests."\n".Would." ".you." ".like." ".to." ".have." ".giveaways." ".$giveaways." ".Basic." ".lighting." ".$basiclighting." ".Fog." ".machine." ".$fogmachine."\n".I." ".also." ".want." ".a." ".$seeking."\n".I." ".am." ".also." ".interested." ".in." ".a." ".$seeking2."\n".Attire." ".$attire."\n".I." ".need." ".the." ".above." ".service." ".for." ".$hours." ".hours."\n".Special." ".Requests."\n."$specialrequests."\n".PARTY." ".LOCATION." ".INFORMATION."\n".$message;


can anyone help me since I can not find where the error is thanks.
this is part of a script that emails form contents to an email address

runesolutions
01-11-2005, 08:56 PM
It might be helpful to have some of the code around that, particularly the bit relating to the 'do' statement.

Although that statement looks a bit odd in itself, but it hurts my eyes.

mjfroggy
01-11-2005, 09:03 PM
here is the whole script
<?php
$to="****@****.com";

$from = $_POST['email'];

$firstname = $_POST['fname'];
$lastname = $_POST['lname'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$dphone = $_POST['dphone'];
$evephone = $_POST['evephone'];
$occasion = $_POST['occasion'];
$eventdate = $_POST['eventdate'];
$raindate = $_POST['raindate'];
$eventstarttime = $_POST['eventstarttime'];
$eventendtime = $_POST['eventendtime'];
$cocktailhour = $_POST['cocktailhour'];
$Recipientname = $_POST['Recipientname'];
$adultsonly = $_POST['adultsonly'];
$numberofadults = $_POST['numberofadults'];
$kidsparty = $_POST['kidsparty'];
$numberofkids = $_POST['numberofkids'];
$mixedguests = $_POST['mixedguests'];
$amountofkids = $_POST['amountofkids'];
$amountofadults = $_POST['amountofadults'];
$giveaways = $_POST['giveaways'];
$basiclighting = $_POST['basiclighting'];
$fogmachine = $_POST['fogmachine'];
$seeking = $_POST['seeking'];
$seeking2 = $_POST['seeking2'];
$attire = $_POST['attire'];
$hours = $_POST['hours'];
$specialrequests = $_POST['specialrequests'];
$message = $_POST['message'];

$subject = 'NewClientInfo';

$body = Spinmaster." ".Entertainment." ".Order." ".Form."\n".PERSONAL." ".INFORMATION."\n".Firstname." ".$firstname." ".Lastname." ".$lastname."\n".Address." ".$address." ".City." ".$city."\n".State." ".$state." ".Zipcode." ".$zip."\n".Daytime." ".Phone." ".$dphone." ".Evening." ".Phone." ".$evephone."\n".Email." ".Address." ".$email."\n".PARTY." ".INFORMATION."\n".Type." ".of." ".occasion." ".$Occasion." ".Event." ".Date." ".$eventdate." ".Rain." ".Date." ".$raindate."\n".Time." ".event." ".starts." ".$eventstarttime." ".End." ".Time." ".$eventendtime."\n".Will." ".their." ".be." ".a." ".cocktail." ".hour." ".$cocktailhour."\n".Recipients." ".name." ".$Recipientname."\n".Will." ".their." ".be." ".adults." ".only." ".$adultsonly." ".How." ".many." ".adults." ".do." ".you." ".expect." ".$numberofadults."\n".Is." ".this." ".a." ".childrens." ".party." ".$kidsparty." ".How." ".many." ".children." ".do." ".you." ".expect." ".$numberofkids."\n".Are." ".you." ".going." ".to." ".have." ".mixed." ".guests." ".$mixedguests."\n".Would." ".you." ".like." ".to." ".have." ".giveaways." ".$giveaways." ".Basic." ".lighting." ".$basiclighting." ".Fog." ".machine." ".$fogmachine."\n".I." ".also." ".want." ".a." ".$seeking."\n".I." ".am." ".also." ".interested." ".in." ".a." ".$seeking2."\n".Attire." ".$attire."\n".I." ".need." ".the." ".above." ".service." ".for." ".$hours." ".hours."\n".Special." ".Requests."\n."$specialrequests."\n".PARTY." ".LOCATION." ".INFORMATION."\n".$message;
/* Send The Email*/
$headers = "From: $from";
if(mail($to, $subject, $body, $headers)){
echo "Email Sent";
}else{
echo "Email Sending Failed";
}
?>

any help thanks

Jason.NXH
01-11-2005, 09:08 PM
The whole string looks messy to me, it is missing alot of things and things look like they are in the wrong order. Try what I have done below.

Original:$body = Spinmaster." ".Entertainment." ".Order." ".Form."\n".PERSONAL." ".INFORMATION."\n".Firstname." ".$firstname." ".Lastname." ".$lastname."\n".Address." ".$address." ".City." ".$city."\n".State." ".$state." ".Zipcode." ".$zip."\n".Daytime." ".Phone." ".$dphone." ".Evening." ".Phone." ".$evephone."\n".Email." ".Address." ".$email."\n".PARTY." ".INFORMATION."\n".Type." ".of." ".occasion." ".$Occasion." ".Event." ".Date." ".$eventdate." ".Rain." ".Date." ".$raindate."\n".Time." ".event." ".starts." ".$eventstarttime." ".End." ".Time." ".$eventendtime."\n".Will." ".their." ".be." ".a." ".cocktail." ".hour." ".$cocktailhour."\n".Recipients." ".name." ".$Recipientname."\n".Will." ".their." ".be." ".adults." ".only." ".$adultsonly." ".How." ".many." ".adults." ".do." ".you." ".expect." ".$numberofadults."\n".Is."
".this." ".a." ".childrens." ".party." ".$kidsparty." ".How." ".many." ".children." ".do." ".you." ".expect." ".$numberofkids."\n".Are." ".you." ".going." ".to." ".have." ".mixed." ".guests." ".$mixedguests."\n".Would." ".you." ".like." ".to." ".have." ".giveaways." ".$giveaways." ".Basic." ".lighting." ".$basiclighting." ".Fog." ".machine." ".$fogmachine."\n".I." ".also." ".want." ".a." ".$seeking."\n".I." ".am." ".also." ".interested." ".in." ".a." ".$seeking2."\n".Attire." ".$attire."\n".I." ".need." ".the." ".above." ".service." ".for." ".$hours." ".hours."\n".Special." ".Requests."\n."$specialrequests."\n".PARTY." ".LOCATION." ".INFORMATION."\n".$message;Replace with:$body = "Spinmaster Entertainment Order Form<br>"
."PERSONAL INFORMATION<br>"
."Firstname: $firstname<br>"
."Lastname: $lastname<br>"
."Address: $address<br>"
."City: $city<br>"
."State: $state<br>"
."Zipcode: $zip<br>"
."Daytime Phone: $dphone<br>"
."Evening Phone: $evephone<br>"
."Email Address: $email<br>"
."PARTY INFORMATION<br>"
."Type of occasion: $Occasion<br>"
."Event Date: $eventdate<br>"
."Rain Date: $raindate<br>"
."Time event starts: $eventstarttime<br>"
."End Time: $eventendtime<br>"
."Will their be a cocktail hour: $cocktailhour<br>"
."Recipients name: $Recipientname<br>"
."Will their be adults only: $adultsonly<br>"
."How many adults do you expect: $numberofadults<br>"
."Is this a childrens party: $kidsparty<br>"
."How many children do you expect: $numberofkids<br>"
."Are you going to have mixed guests: $mixedguests<br>"
."Would you like to have giveaways: $giveaways<br>"
."Basic lighting: $basiclighting<br>"
."Fog machine: $fogmachine<br>"
."I also want a: $seeking<br>"
."I am also interested in a: $seeking2<br>"
."Attire: $attire<br>"
."I need the above service for: $hours hours<br>"
."Special requests: $specialrequests<br>"
."PARTY LOCATION INFORMATION<br>"
."$message";Please let me know if all goes well or not. I've just made the script a little neater and made it all correct, I hope :P

mjfroggy
01-11-2005, 09:15 PM
if I replace by $body code with yours I get this
Parse error: parse error, unexpected T_STRING in /home/jautismn/public_html/spinmaster/processorder.php on line 46
message ???

Jason.NXH
01-11-2005, 09:18 PM
What is on line 46 of processorder.php ??

mjfroggy
01-11-2005, 09:22 PM
."State: $state<br>"

Jason.NXH
01-11-2005, 09:25 PM
Hmm, I've looked at the entire script using your original and then replacing the string with mine, but nothing seems to be wrong.

I'm thinking you might have copied the first post I posted, because I left out a few "s. Try copying it again

mjfroggy
01-11-2005, 09:30 PM
That worked thanks for all your help!!

Jason.NXH
01-11-2005, 09:31 PM
No problems :)

mjfroggy
01-11-2005, 09:36 PM
one fast question the <br> tag does not work it just shows up in the email as <br> anyway to make that tag work??

thanks

Jason.NXH
01-11-2005, 09:37 PM
That's probably because your email client doesn't accept HTML. Let me quickly re-do the string and it should work properly

mjfroggy
01-11-2005, 09:38 PM
no it does cause I use outlook and I always get html emails (i.e.spam)

Jason.NXH
01-11-2005, 09:39 PM
Ok, well the email message is in text format, not HTML

Jason.NXH
01-11-2005, 09:40 PM
Replace with:$body = "Spinmaster Entertainment Order Form\n"
."PERSONAL INFORMATION\n"
."Firstname: $firstname\n"
."Lastname: $lastname\n"
."Address: $address\n"
."City: $city\n"
."State: $state\n"
."Zipcode: $zip\n"
."Daytime Phone: $dphone\n"
."Evening Phone: $evephone\n"
."Email Address: $email\n"
."PARTY INFORMATION\n"
."Type of occasion: $Occasion\n"
."Event Date: $eventdate\n"
."Rain Date: $raindate\n"
."Time event starts: $eventstarttime\n"
."End Time: $eventendtime\n"
."Will their be a cocktail hour: $cocktailhour\n"
."Recipients name: $Recipientname\n"
."Will their be adults only: $adultsonly\n"
."How many adults do you expect: $numberofadults\n"
."Is this a childrens party: $kidsparty\n"
."How many children do you expect: $numberofkids\n"
."Are you going to have mixed guests: $mixedguests\n"
."Would you like to have giveaways: $giveaways\n"
."Basic lighting: $basiclighting\n"
."Fog machine: $fogmachine\n"
."I also want a: $seeking\n"
."I am also interested in a: $seeking2\n"
."Attire: $attire\n"
."I need the above service for: $hours hours\n"
."Special requests: $specialrequests\n"
."PARTY LOCATION INFORMATION\n"
."$message";
Give that a shot

Jason.NXH
01-11-2005, 09:47 PM
Also, if you want to send the email in HTML format, try this:

Replace whole script:<?php

$to = "jason@nitroxhosting.com";
$from = $_POST['email'];

$firstname = $_POST['fname'];
$lastname = $_POST['lname'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$dphone = $_POST['dphone'];
$evephone = $_POST['evephone'];
$occasion = $_POST['occasion'];
$eventdate = $_POST['eventdate'];
$raindate = $_POST['raindate'];
$eventstarttime = $_POST['eventstarttime'];
$eventendtime = $_POST['eventendtime'];
$cocktailhour = $_POST['cocktailhour'];
$Recipientname = $_POST['Recipientname'];
$adultsonly = $_POST['adultsonly'];
$numberofadults = $_POST['numberofadults'];
$kidsparty = $_POST['kidsparty'];
$numberofkids = $_POST['numberofkids'];
$mixedguests = $_POST['mixedguests'];
$amountofkids = $_POST['amountofkids'];
$amountofadults = $_POST['amountofadults'];
$giveaways = $_POST['giveaways'];
$basiclighting = $_POST['basiclighting'];
$fogmachine = $_POST['fogmachine'];
$seeking = $_POST['seeking'];
$seeking2 = $_POST['seeking2'];
$attire = $_POST['attire'];
$hours = $_POST['hours'];
$specialrequests = $_POST['specialrequests'];
$message = $_POST['message'];

$subject = "NewClientInfo";

$body = "Spinmaster Entertainment Order Form\n"
."PERSONAL INFORMATION\n"
."Firstname: $firstname\n"
."Lastname: $lastname\n"
."Address: $address\n"
."City: $city\n"
."State: $state\n"
."Zipcode: $zip\n"
."Daytime Phone: $dphone\n"
."Evening Phone: $evephone\n"
."Email Address: $email\n"
."PARTY INFORMATION\n"
."Type of occasion: $Occasion\n"
."Event Date: $eventdate\n"
."Rain Date: $raindate\n"
."Time event starts: $eventstarttime\n"
."End Time: $eventendtime\n"
."Will their be a cocktail hour: $cocktailhour\n"
."Recipients name: $Recipientname\n"
."Will their be adults only: $adultsonly\n"
."How many adults do you expect: $numberofadults\n"
."Is this a childrens party: $kidsparty\n"
."How many children do you expect: $numberofkids\n"
."Are you going to have mixed guests: $mixedguests\n"
."Would you like to have giveaways: $giveaways\n"
."Basic lighting: $basiclighting\n"
."Fog machine: $fogmachine\n"
."I also want a: $seeking\n"
."I am also interested in a: $seeking2\n"
."Attire: $attire\n"
."I need the above service for: $hours hours\n"
."Special requests: $specialrequests\n"
."PARTY LOCATION INFORMATION\n"
."$message";

/* Send The Email*/
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "To: Spinmaster <jason@nitroxhosting.com>\r\n";
$headers .= "From: $firstname <$from>\r\n";

if (mail($to, $subject, $body, $headers)){
echo "Email Sent";
}
else{
echo "Email Sending Failed";
}

?>
Make sure to edit the 'YOUREMAILHERE@DOMAIN.COM' part

mjfroggy
01-11-2005, 09:54 PM
thanks thats all I needed and its working grath thanks for your time!

Jason.NXH
01-11-2005, 09:57 PM
Okies, no problem

Rich2k
01-12-2005, 09:37 AM
If you want to put HTML in the email you need to add

Content-Type: text/html

to the email headers. Technically you really ought to put

Content-Type: text/plain

in a plain message!

I don't think you need the MIME-Version header just to change to HTML but you do need it to do anything complicated like attachments or multi-part messages. (mind you I tend to only deal with the complicated email structures these days :) )

I would clean up your POST variables first if I was you, especially if you're sending HTML emails as a user could easily inject a security exploit in there.