Jump to content

syntax error


mindapolis

Recommended Posts

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.

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.