Hi all ive had some syntax errors and have managed to correct 2 lines using advice on this forum but now it has came up with this error

Parse error: syntax error, unexpected T_STRING in /home/nebbmhc1/public_html/send_form_email.php on line 18


ive corrected lines 15 and 16 and wonder how many more lines will have errors in as im confused as to how to correct the rest, any help would be greatly appreciated!

thanks

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?php
if(isset($_POST['email'])) {
	
	// EDIT THE 2 LINES BELOW AS REQUIRED
	$email_to = "info@ouremailaddress";
	$email_subject = "Web Enquiry";
	
	
	function died($error) {
		// your error code can go here
		echo "We are very sorry, but there were error(s) found with the form your submitted. ";
		echo "These errors appear below.<br /><br />";
		echo $error."<br /><HTML><HEAD>
<META content='text/html; charset=windows-1252' http-equiv=Content-Type>
<META name=GENERATOR content='MSHTML 8.00.6001.18813'></HEAD>
<BODY><BR>"; echo "Please go back and fix these errors.<BR><BR>"; die(); } // 
validation expected data exists if(!isset($_POST['name']) || 
!isset($_POST['email']) || !isset($_POST['message'])) { died('We are sorry, but 
there appears to be a problem with the form your submitted.'); } $name = 
$_POST['name']; // required $email_from = $_POST['email']; // required $message 
= $_POST['message']; // required $error_message = ""; $email_exp = 
"^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { 
$error_message .= 'The Email Address you entered does not appear to be 
valid.<BR>'; } $string_exp = "^[a-z .'-]+$"; if(!eregi($string_exp,$name)) { 
$error_message .= 'The Name you entered does not appear to be valid.<BR>'; } 
if(strlen($message) &lt; 2) { $error_message .= 'The Message you entered do not 
appear to be valid.<BR>'; } if(strlen($error_message) &gt; 0) { 
died($error_message); } $email_message = "Form details below.\n\n"; function 
clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); 
return str_replace($bad,"",$string); } $email_message .= "Name: 
".clean_string($name)."\n"; $email_message .= "Email: 
".clean_string($email_from)."\n"; $email_message .= "Message: 
".clean_string($message)."\n"; // create email headers $headers = 'From: 
'.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . 
phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?&gt; <!-- include your own success html here -->Thank you for contacting us. Your message has been received by us. We will be in touch very soon. </BODY></HTML>

Recommended Answers

Remove the linebreak after the comment on line 17.

Also, try to put all comments on the line above the code they describe to make reading easier and to prevent syntax errors like this one.

Jump to Post

All 3 Replies

Remove the linebreak after the comment on line 17.

Also, try to put all comments on the line above the code they describe to make reading easier and to prevent syntax errors like this one.

change line 18 to
//validation expected data exists

if(!isset($_POST) ||

thank you ive done that, but now its saying error on line 23, which is the line that is 22 above now?? any ideas please?

Be a part of the DaniWeb community

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