mindapolis Posted April 26, 2011 Share Posted April 26, 2011 when you get an unexpected $end parse error does it always mean you have a mismatched curly bracket? In the below code I can't find any mismatched curly bracket. <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>lab10</title> <style type="text/css"> body { background-color: #ff9999; color: #000000; } </style> </head> <body> <?php //$birthday = $month $day $year( $errors=array(); //begins errors array if(isset($_REQUEST['submit'])) { //if form was submitted validate_input(); //checks for empty fields if(count($errors) !=0) { display_form(); } else { display_form(); } function validate_input(){ global $errors; if($_POST["fname"] == " ") { $errors['fname']="<font color = 'red'> Please enter your first name </font>"; } if($_POST["lname"] == " ") { $errors['name']="<font color = 'red'> Please enter your last name </font>"; } if ($_POST[$month] == "February" || "April" || "June" || "September" || "November" && $day > 30) { $errors['date']="<font color='red'> This is not a valid date. Please enter a valid date </font>"; } $action = $_SERVER['PHP_SELF']; extract ($_POST); echo "<form action= $action method=\"post\">"; if (!isset($_POST['submit'])) { echo <<<HEREDOC First Name: <input name="fname" type="text" size="10" maxlength="20" value = "<?php echo $_POST[fname]; ?>" /><br /> Last Name: <input name="lname" type="text" size="10" maxlength="20" value = "<?php echo $_POST[lname]; ?>" /><br /> When is your birthday? <Select name = "month" value = "<?php echo $_POST[date]; ?>" > HEREDOC; $month=array('January' , 'February' , 'March' , 'April' , 'May', 'June', 'July' , 'August', 'September' , 'October' , 'November' , 'December'); foreach ($month as $value){ print "<option value =\"$value\"> $value </option>\n"; } echo "<select name = \"day\"> \n"; for ($day =1; $day <=31; $day ++) { print "<option value =\"$day\"> $day </option>\n"; } echo <<<HEREDOC <select name = "year"> <br /> HEREDOC; for ($year=2011; $year >=1993; $year--) { print "<option value =\"$year\">$year </option>\n"; } echo <<<HEREDOC </select><br /> What is your favorite programming language? <select name="languages" multiple> <option> Please select one <option> C++ <option> Java <option> Javascript <option> PHP </select><br /> <input name="submit" type="submit" value="SUBMIT" /><input name="reset" type="button" value="RESET" /> </form> HEREDOC; } else { echo "Thank you $fname for your information. As indicated, your birthday is "; } ?> </body> </html> MOD EDIT: . . . BBCode tags added. Quote Link to comment https://forums.phpfreaks.com/topic/234798-syntax-error/ Share on other sites More sharing options...
Pikachu2000 Posted April 26, 2011 Share Posted April 26, 2011 When posting code, please enclose it within the forum's . . . BBCode tags. Quote Link to comment https://forums.phpfreaks.com/topic/234798-syntax-error/#findComment-1206658 Share on other sites More sharing options...
PFMaBiSmAd Posted April 26, 2011 Share Posted April 26, 2011 The error means that php reached the end of your file while it was still expecting to find some php code. This is due to an opening element that is not closed, usually a { that has no matching }. However, it can also be due to strings that are not closed. If your {} are matched, I suspect that one of your your heredoc closing tags isn't the only thing on a line and/or doesn't start in column one of the line. Edit: your issue might also be due to having <?php ?> tags inside your heredoc strings (now that I see the code highlighting and where it stops at in your source code.) Quote Link to comment https://forums.phpfreaks.com/topic/234798-syntax-error/#findComment-1206660 Share on other sites More sharing options...
kenrbnsn Posted April 27, 2011 Share Posted April 27, 2011 You never close your validate_input function, plus there are many other syntax errors in your code. Like "<?php" & "?>" tags in the middle of the HEREDOC blocks. Ken Quote Link to comment https://forums.phpfreaks.com/topic/234798-syntax-error/#findComment-1206684 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.