943,892 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 923
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Dec 1st, 2008
0

please help

Expand Post »
I keep getting this message what is wrong with my sacript???

Parse error: syntax error, unexpected $end in /home/sites/thefieldinggallery.co.uk/web/contact_form.php on line 65

here is the php script:

php Syntax (Toggle Plain Text)
  1. <?php
  2. /* subject and email Variables */
  3. $emailSubject = 'Crazy PHP Scripting';
  4. $webMaster = 'info@thefieldinggallery.co.uk';
  5.  
  6. /* Gathering Data Variables */
  7. $nameField = $_POST['name'];
  8. $surnameField = $_POST['surname'];
  9. $emailField = $_POST['email'];
  10. $telephoneField = $_POST['telephone'];
  11. $commentsField = $_POST['comments'];
  12.  
  13. $body = <<<em
  14. <br><hr><br>
  15. name: $name <br>
  16. surname: $surname <br>
  17. email: $email <br>
  18. telephone: $telephone <br>
  19. comments: $comments <br>
  20. EOD;
  21. $headers = "From: $email\r\n";
  22. $headers ,= "Content-type: text/html\r\n";
  23. $success = mail($webMaster, $emailSubject, $body, $headers);
  24.  
  25. /*Results rendered as HTML */
  26. $theResults = <<<EOD
  27. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  28. <html xmlns="http://www.w3.org/1999/xhtml">
  29. <head>
  30. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  31. <title>Untitled Document</title>
  32. </head>
  33. <body>
  34. <table width="50%" border="0" cellspacing="0" cellpadding="0">
  35. <tr>
  36. <td colspan="2"><img src="images/strap.jpg" alt="header" width="769" height="216" /></td>
  37. </tr>
  38. <tr>
  39. <td width="11%"><div align="center"><a href="index.html">Back to Home</a></div></td>
  40. <td width="89%"><div align="center">
  41. <p>&nbsp;</p>
  42. <p><font color="#FF0000" size="+7"><u>Thank you</u> <font color="#000000">for your we have recived you Questions / Comments and we will reply to you</font> <u>as soon as possible</u></font></p>
  43. </div></td>
  44. </tr>
  45. <tr>
  46. <td>&nbsp;</td>
  47. <td>&nbsp;</td>
  48. </tr>
  49. <tr>
  50. <td>&nbsp;</td>
  51. <td><div align="right">Copyright &copy; <a href="http://www.thefieldinggallery.co.uk">www.thefieldinggallery.co.uk</a></div></td>
  52. </tr>
  53. </table>
  54. </body>
  55. </html>
  56. EOD;
  57. echo "$theresults";
  58. ?>
Last edited by peter_budo; Dec 2nd, 2008 at 8:07 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
addsf1 is offline Offline
5 posts
since Dec 2008
Dec 1st, 2008
0

Re: please help

When using heredoc, you must open and close the variable with the same identifier.
php Syntax (Toggle Plain Text)
  1. $body = <<<em
  2. <br><hr><br>
  3. name: $name <br>
  4. surname: $surname <br>
  5. email: $email <br>
  6. telephone: $telephone <br>
  7. comments: $comments <br>
  8. EOD;
should be:
php Syntax (Toggle Plain Text)
  1. $body = <<<EOD
  2. <br><hr><br>
  3. name: $name <br>
  4. surname: $surname <br>
  5. email: $email <br>
  6. telephone: $telephone <br>
  7. comments: $comments <br>
  8. EOD;

Also, variables in php are case sensitive, so you'll have a blank page unless you change echo "$theresults"; to echo "$theResults";
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Dec 1st, 2008
0

Re: please help

Thank you you are a life saver Cheers bro
Reputation Points: 10
Solved Threads: 0
Newbie Poster
addsf1 is offline Offline
5 posts
since Dec 2008
Dec 1st, 2008
0

Re: please help

Glad to help.
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Dec 1st, 2008
0

Re: please help

Next time, wrap your code in code tags when posting to keep things neat. There are plenty of people here to help out. Keeping things neat will improve your chances of getting help.
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Dec 1st, 2008
0

Re: please help

Im new at this and got it from a tutorial. i don't know how to wrap in a tag sorry its messy!
I do have another question though as it has worked and the mail is coming through but the content of the form isn't attached just the headers. can you see what is wrong there???? i would be most grateful
Reputation Points: 10
Solved Threads: 0
Newbie Poster
addsf1 is offline Offline
5 posts
since Dec 2008
Dec 1st, 2008
0

Re: please help

Wrap the code like so:
[code=php]Code goes here[/code]

As to your problem, your email contains undefined variables. For instance you define namefield as $nameField = $_POST['name']; but in the email you send, you have the undefined variable $name instead of the defined $nameField.
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Dec 1st, 2008
0

Re: please help

OK so do i take that as it should look like this?

$nameField = $_POST['nameField'];

I hope im not doing your head in with the questions but as i said i am a total newby at this
Reputation Points: 10
Solved Threads: 0
Newbie Poster
addsf1 is offline Offline
5 posts
since Dec 2008
Dec 1st, 2008
1

Re: please help

The name the element has in the form goes inside the brackets.
So if your form has
html Syntax (Toggle Plain Text)
  1. <input name="name" type="text" id="name" tabindex="16" />
After the form is submitted, PHP can assign the value posted to the variable. Here we assign the value of the textbox above to the variable $nameField:
php Syntax (Toggle Plain Text)
  1. $nameField=$_POST['name'];
Now if you want to use that variable in your email, you'll need to use the variable just defined.
php Syntax (Toggle Plain Text)
  1. $body = <<<EOD
  2. <br><hr><br>
  3. name: $nameField <br>

Get it??
Reputation Points: 232
Solved Threads: 137
Practically a Master Poster
buddylee17 is offline Offline
665 posts
since Nov 2007
Dec 1st, 2008
0

Re: please help

My Friend as far as i am concerned you are a god in the PHP world
i can not say thank you enough

Cheers

Adam
Reputation Points: 10
Solved Threads: 0
Newbie Poster
addsf1 is offline Offline
5 posts
since Dec 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: how can I have a thumb frame of a movie, like youtube
Next Thread in PHP Forum Timeline: Passing form data to default file of a directory





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC