Parse error: syntax error, unexpected 'warning' (T_STRING), expecting ',' or ';' in /xxxx/index.php on line 56
<p>hey guys was hoping you could help me out..</p>

<p>I've been trying to do a email sending system. Everything's ready, but an error gets in the way. The error:</p>

<pre><code>Parse error: syntax error, unexpected 'warning' (T_STRING), expecting ',' or ';' in /xxxx/index.php on line 56
</code></pre>

<p>Here's my code what i use:</p>

<pre><code>&lt;?php
//This code runs if the form has been submitted
if (array_key_exists('submit', $_POST))
{
// check fields are not empty
$name = trim($_POST['name']);
if (strlen($name) &lt; 3) {
  $error['name'] = 'Name Must be more then 3 characters.';
}

if (strlen($name) &gt; 20) {
  $error['name'] = 'Name Must be less then 20 characters.';
}

// check for valid email address
$email = $_POST['email'];
$pattern = '/^[^@]+@[^srn";,@%]+$/';
if (!preg_match($pattern, trim($email))) {
  $error[] = 'Please enter a valid email address';
}

// check fields are not empty
$message = trim($_POST['message']);
if (strlen($message) &lt; 3) {
  $error['message'] = 'Message Must be more then 3 characters.';
}

// if validation is okay then carry on
if (!$error ) {
//send email
$to = "example@domain.com";
$subject = "Contact for ".$_SERVER['HTTP_HOST']."";
$body = "on ".date('M j, Y')." Information from contact form: Name: $name With the email address of $email Wrote this message: $message";
$additionalheaders = "From: &lt;example@domain.com&gt; ";
$additionalheaders .= "Reply-To: example@domain.com";
if(mail($to, $subject, $body, $additionalheaders))
{
  $sent = true;
}

} // end validation
}// end submit

// If mail is sent
if (isset($sent)) {
 echo "&lt;p&gt;Thank you &lt;/p&gt;";
 echo "&lt;p&gt;We will be in touch shortly &lt;/p&gt;";
} else { // mail not sent show form
 echo "&lt;p&gt;Use this contact form for general enquires&lt;/p&gt;";
 echo "&lt;p&gt;I hate spam and I'm sure you do too, so don't worry your email address will &lt;strong&gt;NOT&lt;/strong&gt; be passed on to any third party's &lt;/p&gt;";

// show any errors if set

echo "&lt;blockquote&gt;";
 if (isset($error['name'])) {
   echo "&lt;p&gt;&lt;span class="warning"&gt;".$error['name']."&lt;/span&gt;&lt;/p&gt; ";
}

 if (isset($error['email'])) {
   echo "&lt;p&gt;&lt;span class="warning"&gt;".$error['email']."&lt;/span&gt;&lt;/p&gt; ";
 }

 if (isset($error['message'])) {
   echo "&lt;p&gt;&lt;span class="warning"&gt;".$error['message']."&lt;/span&gt;&lt;/p&gt; ";
 }

echo "&lt;/blockquote&gt;";
?&gt;

&lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" method="post"&gt;
&lt;fieldset&gt;
&lt;legend&gt;Contact&lt;/legend&gt;
&lt;p&gt;&lt;label&gt;Name:&lt;/label&gt;&lt;input name="name" type="text" maxlength="20" &lt;?php if(isset($error)) {echo "value='$name'";} ?&gt; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;label&gt; Email:&lt;/label&gt;&lt;input name="email" type="text" maxlength="2550" &lt;?php if(isset($error)) {echo "value='$email'";} ?&gt; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;label&gt;Message:&lt;/label&gt;&lt;textarea name="message" cols="50" rows="10" id="message"&gt;&lt;?php if(isset($error)) {echo $message;} ?&gt;&lt;/textarea&gt;&lt;/p&gt;
&lt;p&gt;&lt;input type="submit" name="submit" value="Send Message"&gt;&lt;/p&gt;
&lt;/fieldset&gt;
&lt;/form&gt;
&lt;?php } ?&gt;
</code></pre>

<p>Please don't down note, I'm new here. Thank you in advance.</p>
