0

Hallo
Could some tell me why am getting the following error message.

Parse error: syntax error, unexpected '{' in C:\wamp\www\financialacadem\thank_you.php on line 23

Here are the codes for both the contact.php and the thank_you.php

<form id="contact" action="thank_you.php" method="post">   
    <div class="form-row">
        <label for="first_name">First Name</label>:
        <input name="first_name" id="first_name" class="required" size="30" maxlength="50" title="Please enter your first name." value="">
    </div>
    <div class="form-row">

        <label for="last_name">Last Name</label>:
        <input name="last_name" id="last_name" class="required" size="30" maxlength="50" title="Please enter your last name." value="">
    </div>
    <div class="form-row">
        <label for="email">Email</label>:
        <input name="email" id="email" class="required validate-email" size="30" maxlength="50" title="Please enter your email address." value="">
    </div>
<div class="form-row">
        <label for="phone">Telephone</label>:
        <input name="telephone" id="telephone" class="required"size="15" maxlength="30" title="Please enter your phone number." value="">
        <div style="visibility: visible; opacity: 1;" id="country_phone_tip" class="">
            <img src="images/small_right_arrow.png" alt="arrow" align="absmiddle" height="9" width="8">

            <img id="country_flag" src="images/ke.png" alt="flag" align="absmiddle" height="11" width="16">            
            <em>
                <span class="country_code"><abbr>254</abbr>&nbsp;</span>
                <span class="area_code">(<abbr>xx</abbr>)&nbsp;</span>
                <span class="number_mask"><abbr>xxx-xxx</abbr></span>
            </em>
        </div>

    </div>
    <div class="form-row">
        <label for="time">Best Call Time</label>:<br>
        <select name="time" id="time">
            <option value="any" selected="selected">Any
            </option><option value="1:00">1:00</option>
            <option value="1:30">1:30</option>

            <option value="2:00">2:00</option>
            <option value="2:30">2:30</option>
            <option value="3:00">3:00</option>
            <option value="3:30">3:30</option>
            <option value="4:00">4:00</option>
            <option value="4:30">4:30</option>

            <option value="5:00">5:00</option>
            <option value="5:30">5:30</option>
            <option value="6:00">6:00</option>
            <option value="6:30">6:30</option>
            <option value="7:00">7:00</option>
            <option value="7:30">7:30</option>

            <option value="8:00">8:00</option>
            <option value="8:30">8:30</option>
            <option value="9:00">9:00</option>
            <option value="9:30">9:30</option>
            <option value="10:00">10:00</option>
            <option value="10:30">10:30</option>

            <option value="11:00">11:00</option>
            <option value="11:30">11:30</option>
            <option value="12:00">12:00</option>
            <option value="12:30">12:30</option>
        </select>
        <select name="tt">
            <option value="am" selected="selected">AM</option>

            <option value="pm">PM</option>
        </select>
    </div>    
    <div class="form-row-submit">
        <!--<input type="submit" name="submit_btn" value="Tell Me More!" class="button" title="Continue" />-->
        <input src="images/submit.png" name="submit_btn" value="Tell Me More!" class="submit" title="Continue" type="image">
    </div>
<input name="formid" value="contact" type="hidden"></form>

Thank_you.php

<?php
if(isset($_POST['email'])) {
 
	// EDIT THE 2 LINES BELOW AS REQUIRED
	$email_to = "matotien@gmail.com";
	$email_subject = "Request for Free Introduction";
 
 
	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 /><br />";
		echo "Please go back and fix these errors.<br /><br />";
		die();
	}
 
	// validation expected data exists
	if(!isset($_POST['first_name']) ||
		!isset($_POST['last_name']) ||
		!isset($_POST['email']) ||
		!isset($_POST['telephone']) ||
		!isset ($_POST['time']) || {
		died('We are sorry, but there appears to be a problem with the form your submitted.');		
	}
 
	$first_name = $_POST['first_name']; // required
	$last_name = $_POST['last_name']; // required
	$email_from = $_POST['email']; // required
	$telephone = $_POST['telephone']; //required 
	$time = $_POST['time'];//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,$first_name)) {
  	$error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!eregi($string_exp,$last_name)) {
  	$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  
 $string_exp = "^[0-9 .-]+$";
  if(!eregi($string_exp,$telephone)) {
  	$error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
  }
  
  if(strlen($error_message) > 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 .= "First Name: ".clean_string($first_name)."\n";
	$email_message .= "Last Name: ".clean_string($last_name)."\n";
	$email_message .= "Email: ".clean_string($email_from)."\n";
	$email_message .= "Telephone: ".clean_string($telephone)."\n";
	$email_message .= "Best call Time: ".clean_string($time)."\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);  
?>

<!-- include your own success html here -->
 
 
 
<!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">
<!-- @(#) $Id$ -->
<head>
	<title>Financial Academy &amp; Technology</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="Keywords" content= ""/>
	<meta name="Description" content="" />

	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />

	<link rel="shortcut icon" href="images/financial-logo.jpg" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="css/style.css" />
	<link rel="stylesheet" type="text/css" href="css/customize.css" />
	<link rel="stylesheet" type="text/css" href="css/layout.css" />



</head> 

<body>
<div id="wrap">
	<?php
		include("logo.php");
		?>
<div id="breadcrumb">

<ul>
		<li><a href="index.php" class="">Home</a></li>
		<li><a href="corporate.php" class="">Corporate Training</a></li>
		<li><a href="private.php" class="">Personal Financial Coaching</a></li>
		<li><a href="about.php" class="">About Us</a></li>
		<li><a href="contacts.php" class="active">Contact Us</a></li>
</ul>
	</div>
<div id="main-body">
	<div id="content"> 
		<div class="inside">
			<h1>Thank you for your interest in Financial Literacy Education</h1>
			<h3>Your information has been submitted successfully</h3>
			<p>Congratulatiom on taking an important step towards your success</p>
			<h3>A representative will contact you shortly</h3>
			<p>Would you like to tell a friend about Financial Literacy Education</p>
				</div>
	</div>

<div id="sidebar"> 
	<div class="inside"> 
		
	</div>
</div>
</div> <!--end of main-body-->

<div id="sidebar-2"> 
	<div class="inside">
		</div>
</div>



<?php
include("./include/footer.php");
?>

</div> <!--end of wrap-->

</body> </html>


 
<?
}
?>
3
Contributors
8
Replies
9
Views
7 Years
Discussion Span
Last Post by JRM
0

You got carried away with the || on line 23 of thank_you.php
remove the || just before the brace.

0

I have made the following changes on line 23

// validation expected data exists
	if(!isset($_POST['first_name']) ||
		!isset($_POST['last_name']) ||
		!isset($_POST['email']) ||
		!isset($_POST['telephone']) ||
		!isset ($_POST['time'])){
		died('We are sorry, but there appears to be a problem with the form your submitted.');		
	}

but now am getting the following error message

Parse error: syntax error, unexpected $end in C:\wamp\www\financialacadem\thank_you.php on line 153

Please assist. My client is eager to use the form.

0

These ongoing validation problems can be solved using a code highlighting editor
missing braces etc show error colors on the singleton
the learning curve for a new editor is more than balanced by not having to make this type of call for assistance **edit** so often( there are always other bugs :) ) **/edit **

Notepad2
notepad++
codepad
all include code highlighting

not a solution to THIS particular problem, but intended to assist

Edited by almostbob: n/a

0

Do you mean i space them

<?

}

?>

I get another error


Parse error: syntax error, unexpected $end in C:\wamp\www\financialacadem\thankyou.php on line 155

0

maybe this ?

<?

}

?>

No, I don't see why that is there at all. You are not echoing the html as far as i can see.
Maybe I'm missing something, but if you deleted that piece it may clear the error.

0

When deleted it gives this error


Parse error: syntax error, unexpected $end in C:\wamp\www\financialacadem\thankyou.php on line 149

Look at this code. I just borrowed it from this form which is working perfectly well

Contacts.php

<form name="contacts" method="post" action="contact.php">
                        <p>The fields marked with an asterik must be filled</p>
			<label for="first_name">First Name:*</label><br/>
			   <input type="text" name="first_name" size="19"/><br/>
			   <br/>
                         <label for="Last_name">Last Name:*</label><br/>
			   <input type="text" name="last_name" size="19"/><br/>
			   <br/>
                           <label for="telephone">Telephone Number:</label><br/>
			   <input type="text" name="telephone" size="19"/><br/>
			   <br/>


			   <label for="email">Email:*</label><br/>
			   <input type="text" name="email" size="19"/><br/>
			   <br/>
			   <label for="comments">Message:*</label><br/>
			   <textarea rows="5" name="comments" cols="50"></textarea>
			   <br/>
			   <br/>
			   <input type="submit" value="Submit" name="submit"/>
			</form>

Contact.php

<?php
if(isset($_POST['email'])) {
 
	// EDIT THE 2 LINES BELOW AS REQUIRED
	$email_to = "mrharrisonadika@yahoo.com,matotien@gmail.com";
	$email_subject = "Website Inquiries";
 
 
	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 /><br />";
		echo "Please go back and fix these errors.<br /><br />";
		die();
	}
 
	// validation expected data exists
	if(!isset($_POST['first_name']) ||
		!isset($_POST['last_name']) ||
		!isset($_POST['email']) ||
		//!isset($_POST['telephone']) ||
		!isset($_POST['comments'])) {
		died('We are sorry, but there appears to be a problem with the form your submitted.');		
	}
 
	$first_name = $_POST['first_name']; // required
	$last_name = $_POST['last_name']; // required
	$email_from = $_POST['email']; // required
	//$telephone = $_POST['telephone']; // not required
	$comments = $_POST['comments']; // 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,$first_name)) {
  	$error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!eregi($string_exp,$last_name)) {
  	$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
  	$error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
 /* $string_exp = "^[0-9 .-]+$";
  if(!eregi($string_exp,$telephone)) {
  	$error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
  }*/
  if(strlen($error_message) > 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 .= "First Name: ".clean_string($first_name)."\n";
	$email_message .= "Last Name: ".clean_string($last_name)."\n";
	$email_message .= "Email: ".clean_string($email_from)."\n";
	$email_message .= "Telephone: ".clean_string($telephone)."\n";
	$email_message .= "Comments: ".clean_string($comments)."\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);  
?>
 
<!-- include your own success html here -->
 
 
 


<!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">
<!-- @(#) $Id$ -->
<head>

	<title>Adika & Company Avocates>>Contact Us</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="Keywords" content= "advocate,lawyer"/>
	<meta name="Description" content="" />

	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />

	<link rel="shortcut icon" href="./images/lawyer-logo.jpg" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" href="./css/style.css" />
	<link rel="stylesheet" type="text/css" href="./css/customize.css" />
	<link rel="stylesheet" type="text/css" href="./css/layout.css" />


</head> 

<body>
<div id="wrap">
<div id="breadcrumb">
	
				<ul>
						<li><a href="index.php" class="">Home</a></li>
						<li><a href="profile.php" class="">Firm Profile</a></li>
						<li><a href="practise.php" class="">Practise Areas</a></li>
						<li><a href="members.php" class="">Lawyer Profile</a></li>
						<li><a href="careers.php" class="">Careers</a></li>
						<li><a href="contacts.php" class="active">Our Contacts</a></li>
				</ul>
		</div>
		
		<?php
			include("logo.php");
			?>


<div id="main-body">
	<div id="content"> 
		<div class="inside">
<p> Thank you for contacting us. We will get back to you shortly.</p>
<a href="contacts.php"><input type="submit" value="Back"/></a>

				</div>
	</div>

<div id="sidebar"> 
	<div class="inside">
			</div>
</div>

</div> <!--end of main-body-->

<div id="sidebar-2"> 
	<div class="inside"> 
	</div>
</div>
		<?php
		include("./include/footer.php");
		?>
</div> <!--end of wrap-->

</body> </html>
 
 
 
<?
}
?>

That one is working. The previous form does not have the message (comments) part. Changes have been made on "telephone" and "time".

0

As AlmostBOB says , use a code highlighter to find the syntax errors as they happen . It seems that is what is happening to your code.
Make sure all braces and parenthesis are closed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.