Virtual Mechanics: Community Forums and FAQs
Virtual Mechanics: Community Forums and FAQs
WebDwarf, SiteSpinner, SiteSpinner Pro 'How do I...'
What's wrong with this code?|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Working Mechanic |
<?php
$ForwardTo="comments@MyDomain.com"; $name=$_REQUEST['txtName']; $email=$_REQUEST['txtEmail']; $location=$_REQUEST['txtLocation']; $comment=$_REQUEST['txtAreaComments']; $details=.$txtAreaComments."\n"; mail($ForwardTo, "Customer Comment",$details,"From:$email"); ?> I get the following error when I click the Submit button: Parse error: syntax error, unexpected '.' in /mnt/w0707/d41/s35/b030fc46/www/catering2u.ca/comments.php on line 7 I am following the example in the tutorial but apparently something is different. Thanks for your help. KP> |
||
|
|
Guru 'Geezer' Mechanic |
I think you are missing some things. Try:
<?php $ForwardTo="comments@MyDomain.com"; $name=$_REQUEST['txtName']; $email=$_REQUEST['txtEmail']; $location=$_REQUEST['txtLocation']; $comment=$_REQUEST['txtAreaComments']; $details=$name."\n".$location."\n".$comment."\n"; mail($ForwardTo, "Customer Comment",$details,"From:$email"); ?>Also, some email clients do not recognize "\n" as a new-line, so if you get a jumbled e-mail, change it to "\n\r". |
|||
|
|
Working Mechanic |
Thanks, Larry.
KP> |
|||
|
|
Working Mechanic |
How would I add a sender so that when the email appears in my InBox it shows a name? Right now it only shows an email address in the Sender column and the subject. Thanks again.
|
|||
|
|
Honorary 'Aussie' Mechanic |
Change the last line to
mail($ForwardTo, "Customer Comment",$details,"From:$email",”Name:$name”); I think . . . Larry will have to confirm if that doesn’t work. |
|||
|
|
Working Mechanic |
Hi postr, thanks for replying. However I got the following message:
Parse error: syntax error, unexpected ':' in /mnt/w0707/d41/s35/b030fc46/www/catering2u.ca/comments.php on line 10 On the good news I think I found a solution. After trying several different search terms in Google and Yahoo! I finally found a solution that seems to be working: $sender=$name."<".$email.">"; mail($recipient, "Customer Comment",$details,"From:$sender"); Maybe this will be of help to someone with the same problem. KP> |
|||
|
|
Honorary 'Aussie' Mechanic |
I’m glad you have found a solution of sorts, but I wonder about the Parse error you were receiving.
There are only seven lines in your script, so getting an error on line 10 suggests you are (were) missing a closing of either the script itself or one of your lines, and the script is still looking where to go. Of course, the error may have been in the line I suggested. |
|||
|
|
Guru 'Geezer' Mechanic |
Just a guess, but I believe the addition of the "Name: $name" parameter is causing the parse error. According to the PHP manual, the string following the headers parameter ("From: $email") is used for additional flags to be used as command line options by the mail program. If "Name:" is not a valid parameter, the ":" would trigger the PHP processor to issue a parse error.
Also, according to the PHP manual, the method to enclose a common name as part of the From parameter is as KP has shown:
|
|||
|
| Powered by Eve Community |
| Please Wait. Your request is being processed... |
|

