twilitegxa Posted August 3, 2011 Share Posted August 3, 2011 Can anyone tell me what is causing the error unexpected $end? (Parse error[/size]: syntax error, unexpected $end in[/size] [/size]/home/content/13/6397313/html/annuities.php[/size] [/size]on line[/size] [/size]54): <?php if(isset($_POST['submit'])) { if(trim($_POST['name']) == '') { $hasError = true; } else { $name = trim($_POST['name']); }$phone = $_POST["phone"]; if(trim($_POST['email']) == '') { $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); if(trim($_POST['message']) == '') { $hasError = true; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['message'])); } else { $comments = trim($_POST['message']); } } if(!isset($hasError)) { $emailTo = '[email protected]'; $subject = 'More Information Request : Annuities'; $body = "Name: $name \n\nEmail: $email \n\nPhone: $phone $comments"; $headers = 'From: tominsurance.com <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> <?php if(isset($hasError)) { ?> <p class="error">Please check if you've filled all the fields with valid information. Thank you.</p> <?php } ?> <?php if(isset($emailSent) && $emailSent == true) { ?> <p><strong>Email Successfully Sent!</strong></p> <p>Thank you <strong><?php echo $name;?></strong> for requesting more information from us! Your email was successfully sent and we will be in touch with you soon.</p> <?php } ?> <html> <head> <meta http-equiv="Refresh" content="4;url=annuities.html"> </head> <body> </body> </html> Link to comment https://forums.phpfreaks.com/topic/243673-unexpected-end/ Share on other sites More sharing options...
xyph Posted August 3, 2011 Share Posted August 3, 2011 Probably missing a closing } somewhere. } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); if(trim($_POST['message']) == '') { To be helpful, you don't have to even use curly braces if there's only one 'line' being used in an IF/THEN statement. For example, this is fine code if( $a = $b ) echo 'A is B'; elseif( $a = $c ) someFunction( $arguments ); else die( 'foobar' ); Link to comment https://forums.phpfreaks.com/topic/243673-unexpected-end/#findComment-1251092 Share on other sites More sharing options...
twilitegxa Posted August 6, 2011 Author Share Posted August 6, 2011 I found it, thanks! Link to comment https://forums.phpfreaks.com/topic/243673-unexpected-end/#findComment-1253079 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.