By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,620 Members | 1,512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,620 IT Pros & Developers. It's quick & easy.

Sending to email Problem: "unexpected T_ENCAPSED_AND_WHITESPACE"

crystal2005
P: 44
I found such eror message when i tried to test sending email.

Expand|Select|Wrap|Line Numbers
  1. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /www/110mb.com/h/e/a/v/e/n/t/u/heaventure/htdocs/send_contact.php on line 10
  2.  
Do we have to set something on the hosting server in order to be able to send message??

This is my code that i encountered the problem

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //--Sending Contact--
  3.  
  4. session_start();
  5.  
  6. // Contact subject
  7. $subject   = $_POST['subject'];
  8. $message   = $_POST['detail'];
  9. $mail_from = $_POST['customer_mail'];
  10. $header    = "from: $_POST['name'] <$_POST['mail_from']>";
  11.  
  12. // Enter your email address
  13. $to = "__MUNGED__";
  14.  
  15. $send_contact = mail($to,$subject,$message,$header);
  16.  
  17. // Check, if message sent to your email
  18. // display message "We've recived your information"
  19. if($send_contact)
  20.   {
  21.     echo "We've received your email ...";
  22.     echo "<p><input type = button value = 'Back To LOGIN Menu' OnClick = parent.document.location='index.html'>";
  23.  
  24.   }
  25. else 
  26.   {
  27.     echo "Error ... Can't Send email to Admin (Email Server not responding)...";
  28.     echo "<p><input type = button value = 'Back To Contact Form' OnClick = self.history.back()>";
  29.   }
  30. ?>
  31.  
Oct 21 '07 #1
Share this Question
Share on Google+
3 Replies


pbmods
Expert 5K+
P: 5,821
Heya, Crystal.

In this line:
Expand|Select|Wrap|Line Numbers
  1. $header    = "from: $_POST['name'] <$_POST['mail_from']>";
  2.  
You need to enclose your variables in curly braces:

Expand|Select|Wrap|Line Numbers
  1. $header    = "from: {$_POST['name']} <{$_POST['mail_from']}>";
  2.  
http://php.net/manual/en/language.ty...arsing.complex
Oct 21 '07 #2

crystal2005
P: 44
Thanks a lot man, now it works. I'm still newbie in PHP.
Oct 21 '07 #3

pbmods
Expert 5K+
P: 5,821
Heya, Crystal.

We'll see what we can do about that.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Oct 21 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.