Guys, I keep getting this error with the code below, please help.
"Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' "
------------------------------------
<?php
$smtp="xxx.xxx.com";
$mail_form="xxxnewsletter@xxx.com";
$to = "xxx@xxx.com";
$subject = "Subscribe to xxx Newsletter";
ini_set("SMTP", $smtp);
ini_set("sendmail_from", $mail_form);
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
mail($to, $subject, "<html>
<head>
<title>Subsribe to xxx Newsletter</title>
</head>
<body>
<p>
<br>Title: <b><?php echo $_POST["title"]; ?></b>
<br>Name: <b><?php echo $_POST["name"]; ?></b>
<br>Company: <b><?php echo $_POST["company"]; ?></b>
<br>Address: <b><?php echo $_POST["address1"]; ?></b>
<br>City: <b><?php echo $_POST["city"]; ?></b>
<br>State: <b><?php echo $_POST["state"]; ?></b>
<br>ZIP: <b><?php echo $_POST["zip"]; ?></b>
<br>Country: <b><?php echo $_POST["country"]; ?></b>
<br>Phone: <b><?php echo $_POST["phone"]; ?></b>
<br>E-Mail: <b><?php echo $_POST["email"]; ?></b>
</body>
</html>", $headers);
?>
how to send html mail
Moderator: General Moderators
Well, you don't need the "<?php" and "?>" tags in your message, because you are still in php mode there. Something like:
should work better.
Code: Select all
<br>Title: <b>".$_POSTї"title"]."</b>Hmmm...let's see...
To reduce confusion, I'd recommend putting the body of the message into one string variable like $message, ie:
$message = "<head>"
.= "<title>Subscribe to xxx Newsletter</title>"...and so forth.
then use that in the mail function
mail($to, $subject, $message, $headers);
Also, you can get rid of the <?php ?> brackets as someone has already mentioned.
$message = "<head>"
.= "<title>Subscribe to xxx Newsletter</title>"...and so forth.
then use that in the mail function
mail($to, $subject, $message, $headers);
Also, you can get rid of the <?php ?> brackets as someone has already mentioned.
-
phpnewbie2
- Forum Newbie
- Posts: 2
- Joined: Wed Jun 25, 2003 3:56 pm
Thanks Galahad, I finally got it to work!Galahad wrote:Well, you don't need the "<?php" and "?>" tags in your message, because you are still in php mode there. Something like:should work better.Code: Select all
<br>Title: <b>".$_POSTї"title"]."</b>
why use multiple? i had something i set up $message="small write upGalahad wrote:Well, you don't need the "<?php" and "?>" tags in your message, because you are still in php mode there. Something like:should work better.Code: Select all
<br>Title: <b>".$_POSTї"title"]."</b>
userame is $user
pass is $pass
validationcode is..."worked fine. why not just go...
$message='<html><head><title>Subsribe to xxx Newsletter</title><body><p><br>Title: <b>'.$_POST["title"].'</b><br /><br>Name: <b>'.$_POST["name"].'</b><br /><br>Company: <b>'.$_POST["company"].'</b><br /><br>Address: <b>'.$_POST["address1"].'</b><br /><br>City: <b>'.$_POST["city"].'</b>
<br>State: <b>'.$_POST["state"].'</b><br /><br>ZIP: <b>'.$_POST["zip"].'</b><br /><br>Country: <b>'.$_POST["country"].'</b><br /><br>Phone: <b>'.$_POST["phone"].'</b><br /><br>E-Mail: <b>'.$_POST["email"].'</b><br /></body></html>'
note my use of <br /> which you forgot. in the future that may be needed. also note the use of ' instead of "
i did that because arrays insside fo " got me and i decided it's neater just to get out of the string, and since i don't want a chace at that being evaluated cause everything evaluated is outside, i used '
personally i feel itt's neater code, if you make a mistake that you're more likely to see it that way..at least that's my personal opinion (and i do expect you'll test it with yourself at some point