Help with some PHP

Associate
Joined
13 Nov 2006
Posts
41
Location
Solihull
Hi all,

I have been attempting to make a contact form through use of CSS and php. I have placed the necessary files in the web server, but I am getting an error message, which reads:

Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\contact.php on line 10

The code for the whole page is:

Code:
<?php
if (isset($_POST['Submit'])) {
	 $name = $_POST['name'];
	 $email = $_POST['email'];
	 $comments = $_POST['comments'];
	 $mailing = $_POST['mailing'];
	 if($name == '' or $email == '' or $comments == '') {
		$err = true;
		$msg = 'Please complete your name, email address and comments to submit the form.';
	 }
}
?>
<!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=iso-8859-1" />
<title>Liquid Crystal Art Contact Page</title>
<link href="contact.css" rel="stylesheet" title="Contact" type="text/css" />
</head>

<body>
<?php
if($err == true) {
	echo '<p class="error">'. $msg . '</p>';
}
?>
<form id="form1" name="form1" method="post" action="">
  <div>
    <label for="name">Name</label>
    <input name="name" type="text" class="text" id="name" />
    <div>
      <label for="email">Email Address</label>
      <input name="email" type="text" class="text" id="email" />
    </div>
    <div>
      <label for="comments">Comments</label>
      <textarea name="comments" cols="30" rows="6" class="text" id="comments"></textarea>
      <div>
        <label for="mailing">Add me to your mailing list</label>
        <input type="checkbox" name="mailing" value="true" id="mailing" />
        <div>
          <input name="Submit" type="submit" class="btn" value="Submit" />
        </div>
      </div>
    </div>
  </div>
</form>
</body>
</html>

I have actually been following a tutorial and I have carefully checked the code compared to what they published and it all seems to be ok from a copying front. I am using the latest version of XAMPP, which should be fine with the code I think. Any help greatly appreciated.

Cheers

Ross
 
chesterstu said:
It's because on Line 10 there is an extra bracket that you don't need. So just remove the last }

OK, I have removed the bracket, know I am getting a new error:

Parse error: syntax error, unexpected $end in C:\xampp\htdocs\contact.php on line 50

But the document ends on line 49, so what is that all about?

Cheers
 
I have been reading around and this seems to suggest that there is a missing curly bracket. Perhaps caused by the one that I removed from above. Any advice?
 
I have put the curly bracket back ind checked that they are paired correctly in PHP designer and I dont appear to be missing anything.

Strangely I have not retested it and it appears to be working fine, how very strange. Thanks for the help though.

Ross
 
Back
Top Bottom