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
/* subject and email Variables */
 $emailSubject = 'Crazy PHP Scripting';
 $webMaster = 'info@thefieldinggallery.co.uk';
 
/* Gathering Data Variables */
 $nameField = $_POST['name'];
 $surnameField = $_POST['surname'];
 $emailField = $_POST['email'];
 $telephoneField = $_POST['telephone'];
 $commentsField = $_POST['comments'];
 
  $body = <<<em
<br><hr><br>
name: $name <br>
surname: $surname <br>
email: $email <br>
telephone: $telephone <br>
comments: $comments <br>
EOD;
 $headers = "From: $email\r\n";
 $headers ,= "Content-type: text/html\r\n";
 $success = mail($webMaster, $emailSubject, $body, $headers);
 
/*Results rendered as HTML */
 $theResults = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="50%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2"><img src="images/strap.jpg" alt="header" width="769" height="216" /></td>
  </tr>
  <tr>
    <td width="11%"><div align="center"><a href="index.html">Back to Home</a></div></td>
    <td width="89%"><div align="center">
      <p>&nbsp;</p>
      <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>
    </div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="right">Copyright &copy; <a href="http://www.thefieldinggallery.co.uk">www.thefieldinggallery.co.uk</a></div></td>
  </tr>
</table>
</body>
</html>
EOD;
echo "$theresults";
?>

When using heredoc, you must open and close the variable with the same identifier.

$body = <<<em
<br><hr><br>
name: $name <br>
surname: $surname <br>
email: $email <br>
telephone: $telephone <br>
comments: $comments <br>
EOD;

should be:

$body = <<<EOD
<br><hr><br>
name: $name <br>
surname: $surname <br>
email: $email <br>
telephone: $telephone <br>
comments: $comments <br>
EOD;

Also, variables in php are case sensitive, so you'll have a blank page unless you change echo "$theresults"; to echo "$theResults";

Thank you you are a life saver Cheers bro

Glad to 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.

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

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.

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

$nameField = $_POST;

I hope im not doing your head in with the questions but as i said i am a total newby at this

The name the element has in the form goes inside the brackets.
So if your form has

<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:

$nameField=$_POST['name'];

Now if you want to use that variable in your email, you'll need to use the variable just defined.

$body = <<<EOD
<br><hr><br>
name: $nameField <br>

Get it??

commented: Nicely done +12

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

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

You can thank to buddylee17, just click on "Add to buddylee17 reputation" in the post that deserves it. There you can also leave short message with your thanks which other member can see and of course mark thread as solved (which you already did)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.