473,714 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to fix parse error: syntax error, unexpected $end in

Parse error: syntax error, unexpected $end in

I keep getting that, I have no clue where to fix it. Any help would be VERY APPRECIATED!

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. if(isset($_POST['email'])) {
  4.  
  5.     // EDIT THE 2 LINES BELOW AS REQUIRED
  6.     $email_to = "tony@example.com";
  7.     $email_subject = "New Email from CASE EVALUATION form in email";
  8.  
  9.  
  10.     function died($error) {
  11.         // your error code can go here
  12.         echo "We are very sorry, but there were error(s) found with the form your submitted. ";
  13.         echo "These errors appear below.<br /><br />";
  14.         echo $error."<br /><br />";
  15.         echo "Please go back and fix these errors.<br /><br />";
  16.         die();
  17.     }
  18.  
  19.     // validation expected data exists
  20.     if(!isset($_POST['full_name']) ||
  21.         !isset($_POST['address']) ||
  22.         !isset($_POST['phone']) ||
  23.         !isset($_POST['email']) ||
  24.         !isset($_POST['best']) ||
  25.         !isset($_POST['role_in_matter']) ||
  26.         !isset($_POST['where']) ||
  27.         !isset($_POST['when']) ||
  28.         !isset($_POST['what']) ||
  29.         !isset($_POST['what_two']) ||
  30.         !isset($_POST['what_three']) ||
  31.         !isset($_POST['comments'])) {
  32.         died('We are sorry, but there appears to be a problem with the form your submitted.');        
  33.     }
  34.  
  35.     $full_name = $_POST['full_name']; // required
  36.     $address = $_POST['address']; // required
  37.     $phone = $_POST['phone']; // required
  38.     $email = $_POST['email']; // required
  39.     $best = $_POST['best']; // required
  40.     $role_in_matter = $_POST['role_in_matter']; // required
  41.     $where = $_POST['where']; // required
  42.     $when = $_POST['when']; // required
  43.     $what = $_POST['what']; // required
  44.     $what_two = $_POST['what_two']; // not required
  45.     $what_three = $_POST['what_three']; // not required
  46.     $comments = $_POST['comments']; // required
  47.  
  48.     $error_message = "";
  49.     $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  50.   if(!eregi($email_exp,$full_name)) {
  51.       $error_message .= 'The text you entered does not appear to be valid.<br />';
  52.   }
  53.     $string_exp = "^[a-z0-9 .'-]+$";
  54.   if(!eregi($string_exp,$address)) {
  55.       $error_message .= 'The text you entered does not appear to be valid.<br />';
  56.   }
  57.   $string_exp = "^[a-z0-9 .'-]+$";
  58.   if(!eregi($string_exp,$phone)) {
  59.       $error_message .= 'The text you entered does not appear to be valid.<br />';
  60.   }  
  61.   $string_exp = "[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  62.   if(!eregi($string_exp,$email)) {
  63.       $error_message .= 'The text you entered does not appear to be valid.<br />';
  64.   }  
  65.   $string_exp = "^[a-z0-9 .'-]+$";
  66.   if(!eregi($string_exp,$best)) {
  67.       $error_message .= 'The text you entered does not appear to be valid.<br />';
  68.   }  
  69.   $string_exp = "^[a-z0-9]+$";
  70.   if(!eregi($string_exp,$role_in_matter)) {
  71.       $error_message .= 'The text you entered does not appear to be valid.<br />';
  72.   }  
  73.   $string_exp = "^[a-z0-9 .'-]+$";
  74.   if(!eregi($string_exp,$where)) {
  75.       $error_message .= 'The text you entered does not appear to be valid.<br />';
  76.   }  
  77.   $string_exp = "^[a-z0-9 .'-]+$";
  78.   if(!eregi($string_exp,$when)) {
  79.       $error_message .= 'The text you entered does not appear to be valid.<br />';
  80.   }  
  81.   if(!eregi($string_exp,$what)) {
  82.       $error_message .= 'The text you entered does not appear to be valid.<br />';
  83.   }
  84.   $string_exp = "^[a-z0-9 .'-]+$";
  85.   if(!eregi($string_exp,$what_two)) {
  86.       $error_message .= 'The text you entered does not appear to be valid.<br />';
  87.  
  88.   $string_exp = "^[a-z0-9 .'-]+$";
  89.   if(!eregi($string_exp,$what_three)) {
  90.       $error_message .= 'The text you entered does not appear to be valid.<br />';
  91.   }
  92.   if(strlen($comments) < 2) {
  93.       $error_message .= 'The pertinent information you entered do not appear to be valid.<br />';
  94.   }
  95.  
  96.   if(strlen($error_message) > 0) {
  97.       died($error_message);
  98.   }
  99.     $email_message = "Form details below.\n\n";
  100.  
  101.     function clean_string($string) {
  102.       $bad = array("content-type","bcc:","to:","cc:","href");
  103.       return str_replace($bad,"",$string);
  104.     }
  105.  
  106.     $email_message .= "Full Legal Name: ".clean_string($full_name)."\n";
  107.     $email_message .= "Your address: ".clean_string($address)."\n";
  108.     $email_message .= "Your phone number: ".clean_string($phone)."\n";
  109.     $email_message .= "Your email address: ".clean_string($email)."\n";
  110.     $email_message .= "Best time and way to contact you: ".clean_string($best)."\n";
  111.     $email_message .= "Your role in this matter: ".clean_string($role_in_matter)."\n";
  112.     $email_message .= "Where was the ticket received?: ".clean_string($where)."\n";
  113.     $email_message .= "When did you receive it? There are strict deadlines, so this is very important.: ".clean_string($when)."\n";
  114.     $email_message .= "What type of law enforcement officer stopped you?: ".clean_string($what)."\n";
  115.     $email_message .= "What is the allegation? : ".clean_string($what_two)."\n";
  116.     $email_message .= "What court your case is in: ".clean_string($what_three)."\n";
  117.     $email_message .= "Other Pertinent Information: ".clean_string($comments)."\n";
  118.  
  119.  
  120. // create email headers
  121. $headers = 'From: '.$full_name."\r\n".
  122. 'Reply-To: '.$full_name."\r\n" .
  123. 'X-Mailer: PHP/' . phpversion();
  124. @mail($email_to, $email_subject, $email_message, $headers);  
  125. ?>
  126.  
  127.  
Nov 2 '10 #1
5 4216
Atli
5,058 Recognized Expert Expert
The rest of the error, the part you didn't post, is the part that tells you where the error occurs. If you want us to be able to help locate it, we need to see that as well.

This error, however, usually indicates that your brackets are out of order. Make sure you close all conditional blocks and functions properly.
Nov 2 '10 #2
Markus
6,050 Recognized Expert Expert
Looks like you haven't closed that main if(). This is why programmers love consistent formatting.
Nov 2 '10 #3
Dormilich
8,658 Recognized Expert Moderator Expert
it looks like there should be a } on line #87.
Nov 2 '10 #4
Thank you for the responses guys. Here is my PHP for the site. There is something wrong, can anyone identity it? I would really appreciate it.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(isset($_POST['email'])) {
  3.  
  4.     // EDIT THE 2 LINES BELOW AS REQUIRED
  5.     $email_to = "renewalhomerestoration@gmail.com";
  6.     $email_subject = "New Email from contact form in email";
  7.  
  8.  
  9.     function died($error) {
  10.         // your error code can go here
  11.         echo "We are very sorry, but there were error(s) found with the form your submitted. ";
  12.         echo "These errors appear below.<br /><br />";
  13.         echo $error."<br /><br />";
  14.         echo "Please go back and fix these errors.<br /><br />";
  15.         die();
  16.     }
  17.  
  18.     // validation expected data exists
  19.     if(!isset($_POST['first_name']) ||
  20.         !isset($_POST['last_name']) ||
  21.         !isset($_POST['email']) ||
  22.         !isset($_POST['telephone']) ||
  23.         !isset($_POST['comments'])) {
  24.         died('We are sorry, but there appears to be a problem with the form your submitted.');        
  25.     }
  26.  
  27.     $first_name = $_POST['first_name']; // required
  28.     $last_name = $_POST['last_name']; // required
  29.     $email_from = $_POST['email']; // required
  30.     $telephone = $_POST['telephone']; // not required
  31.     $comments = $_POST['comments']; // required
  32.  
  33.     $error_message = "";
  34.     $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  35.   if(!eregi($email_exp,$email_from)) {
  36.       $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  37.   }
  38.     $string_exp = "^[a-z .'-]+$";
  39.   if(!eregi($string_exp,$first_name)) {
  40.       $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  41.   }
  42.  
  43.   if(!eregi($string_exp,$last_name)) {
  44.       $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  45.   }
  46.   if(strlen($comments) < 2) {
  47.       $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  48.   }
  49.   $string_exp = "^[0-9 .-]+$";
  50.   if(!eregi($string_exp,$telephone)) {
  51.       $error_message .= 'The Telphone Number you entered does not appear to be valid.<br />';
  52.   }
  53.   if(strlen($error_message) > 0) {
  54.       died($error_message);
  55.   }
  56.     $email_message = "Form details below.\n\n";
  57.  
  58.     function clean_string($string) {
  59.       $bad = array("content-type","bcc:","to:","cc:","href");
  60.       return str_replace($bad,"",$string);
  61.     }
  62.  
  63.     $email_message .= "First Name: ".clean_string($first_name)."\n";
  64.     $email_message .= "Last Name: ".clean_string($last_name)."\n";
  65.     $email_message .= "Email: ".clean_string($email_from)."\n";
  66.     $email_message .= "Telephone: ".clean_string($telephone)."\n";
  67.     $email_message .= "Comments: ".clean_string($comments)."\n";
  68.  
  69.  
  70. // create email headers
  71. $headers = 'From: '.$email_from."\r\n".
  72. 'Reply-To: '.$email_from."\r\n" .
  73. 'X-Mailer: PHP/' . phpversion();
  74. @mail($email_to, $email_subject, $email_message, $headers);  
  75. ?>

Here is the HTML for the form if this helps.

Expand|Select|Wrap|Line Numbers
  1. <form name="contact" method="post" action="contactform.php">
  2. <table width="550px">
  3. </tr>
  4. <tr>
  5.  <td valign="top">
  6.   <label for="first_name">First Name</label>
  7.  </td>
  8.  <td valign="top">
  9.   <input  type="text" name="first_name" maxlength="50" size="30">
  10.  </td>
  11. </tr>
  12.  
  13.  <td valign="top">
  14.   <label for="last_name">Last Name</label>
  15.  </td>
  16.  <td valign="top">
  17.   <input  type="text" name="last_name" maxlength="50" size="30">
  18.  </td>
  19. </tr>
  20. <tr>
  21.  <td valign="top">
  22.   <label for="email">Return Email</label>
  23.  </td>
  24.  <td valign="top">
  25.   <input  type="text" name="email" maxlength="80" size="30">
  26.  </td>
  27.  
  28. </tr>
  29. <tr>
  30.  <td valign="top">
  31.   <label for="telephone">Phone Number</label>
  32.  </td>
  33.  <td valign="top">
  34.   <input  type="text" name="telephone" maxlength="30" size="30">
  35.  </td>
  36. </tr>
  37. <tr>
  38.  <td valign="top">
  39.   <label for="comments">Comments</label>
  40.  </td>
  41.  <td valign="top">
  42.   <textarea  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
  43.  </td>
  44.  
  45. </tr>
  46. <tr>
  47.  <td colspan="2" style="text-align:center">
  48.   <input type="submit" value="Submit">
  49.  </td>
  50. </tr>
  51. </table>
  52. </form>
And finally, here is the error when you use the contact form:

Parse error: syntax error, unexpected $end in D:\Hosting\5235 613\html\newsit e\contactform.p hp on line 112
Nov 3 '10 #5
Markus
6,050 Recognized Expert Expert
Please do not repost the same question.

You have been given an answer 3 times.
Nov 3 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
46195
by: Wescotte | last post by:
The error message Parse error: syntax error, unexpected $end in FILE on line X is one I run into frequently and I know the cause is I missed an ending quote. Is there an easy way to determine where the inital " started? I find myself adding /* */ blocks or cutting/pasting sections of code out in order to find where the error occured. Wouldn't it it be nice if the warning message included the line in teh source where the initial quote ...
5
10029
praclarush
by: praclarush | last post by:
I've just started php, and this is a class assignment, but my question is Iím getting this error PHP Parse error: syntax error, unexpected T_IF, expecting T_VARIABLE or '$' in C:\wamp\www\ssp\SSP04\guessingGame.php on line 42. Iíve tried to make sense of it but Iím at a lose, there error is referring to this segment of the code. else{ if(!isset($_GET)){ echo "<p>****</p>"; $guess = "****"; }//end if //declaring some...
9
4030
by: ajd335 | last post by:
Hi all... I am getting an error Parse error: syntax error, unexpected $end in http:/..... on line 117...(117 is the EOF).. can you plz help me out..I have checked out for the < , > ,{ ,} etc.... I donno where m wrong.... <?php class S_Shipping { // Private variables.
9
3530
akohistani
by: akohistani | last post by:
I am having Parse error problem with my newly purchased Php upload script I have uploaded the script and I get the error below Parse error: syntax error, unexpected $end in URL/functions.php on line 400 Someone please help me I contacted the owner of the script where I purchased he is not replying me I bought it from http://www.scubadivingcalculators.com/ and this is the url where I have uploaded the script...
10
5665
by: benicio | last post by:
Parse error: syntax error, unexpected T_STRING, expecting '(' in C:\wamp\www\study_group\includes\functions.php on line 19 I got this error and this syntax is from 8 to 19th line. <?php $subject_set = get_all_subjects(); while ($subject = mysql_fetch_array($subject_set)) { echo "<li>{$subject}</li>"; $page_set = get_pages_for_subject($subject);
2
3011
by: TanjaPetro | last post by:
Hello to everyone. I changed a few files on my site and when I tried to log into the admin area I got this message: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/secretsh/public_html/shop/admin/includes/boxes/catalog.php on line 31 Line 31 is line 16 below. This is the code in the file:
13
3795
Topbidder
by: Topbidder | last post by:
I have this error on the code Parse error: syntax error, unexpected '"' in /home/topbidd/public_html/bid2/bid_classic.php on line 159 now i thought the error was this It seems that the code has an extra " at the end before the ; VALUES('" .$auction_id. "','" .$user_id. "','" .converttonum(get_next_bid($auction_id)). "','" .$NOW. "')";
3
2655
by: CYNTHIA CUTRER | last post by:
<!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" xml:lang="en"> <head> <title>Log</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="title" content="Walker Energy Brokerage" /> <meta name="description" content="National Energy Brokering Firm" /> <meta...
3
2618
by: Ann Madden | last post by:
Hello - I am super green to php and mysql. I have received the following error: Parse error: syntax error, unexpected $end in C:\website\chart.php on line 84... I have been through the code matching all of my {}, , "", and '', and I can't find anything mis-matched. Also, there is no line 84. Any insights would be greatly appreciated. The code ia as follows: <?php $conn = @new mysqli('localhost', 'root', 'bonkers1', 'prodtestdata'); ...
0
8817
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9322
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9193
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9037
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7963
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectóplanning, coding, testing, and deploymentówithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4472
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4734
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3170
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.