Jump to content

Parse error, unexpected $end help


PRodgers4284

Recommended Posts

Im getting a Parse error: syntax error, unexpected $end, when i run a php script im working on, ive looked at the code and i cant same to find where the error is, can anyone help me here, my code look like this:

 

<?php 
$error_stat = 0; 
$jobtitle_message = '';
$jobcatergory_message = '';
$joblocation_message = '';
$employmenttype_message = '';
$salary_message = '';
$date_message = '';
$educationallevel_message = '';
$description_message = '';

if (isset($_POST['submit'])) { 

$jobtitle = $_POST['jobtitle']; 
$jobcatergory = $_POST['jobcatergory']; 
$joblocation = $_POST['joblocation']; 
$employmenttype= ($_POST['employmenttype']); 
$salary = $_POST['salary']; 
$date = $_POST['date']; 
$educationallevel = $_POST['educationallevel']; 
$description = $_POST['description']; 


//Error checking 

// Job Title check) 
if (!$jobtitle) {
//Set the error_stat to 1, which means that an error has occurred
$error_stat = 1;

//Set the message to tell the user to enter a username
$jobtitle_message = '*Please enter a job title*';
}

else if (ctype_digit($jobtitle)) { 
   $error_stat = 1; 
   $jobtitle_message .= '*Invalid job title*'; 
} 

   if (strlen($jobtitle) > 20){ 
   $error_stat = 1; 
   $jobtitle_message = '*Job title must be 20 characters or less*'; 
} 

//	Job Catergory Check)  
if ($jobcatergory == 'Please Select'){
//Set the error_stat to 1, which means that an error has occurred
$error_stat = 1;
$jobcatergory_message = '*Please select a Job Catergory*';
}

//	Job Location Check)  
if ($joblocation == 'Please Select'){
//Set the error_stat to 1, which means that an error has occurred
$error_stat = 1;
$joblocation_message = '*Please select a Job location*';
}

//	Job Location Check)  
if ($employmenttype == 'Please Select'){
//Set the error_stat to 1, which means that an error has occurred
$error_stat = 1;
$employmenttype_message = '*Please select Employment type*';
}

// Salary check) 
if (!$salary) {
//Set the error_stat to 1, which means that an error has occurred
$error_stat = 1;

//Set the message to tell the user to enter a username
$salary_message = '*Please enter job salary*';
}

//Date check) 
if (empty($date)) {
//Set the error_stat to 1, which means that an error has occurred
$error_stat = 1;

//Set the message to tell the user to enter a dob
$date_message = '*Please enter job closing date*';
}

//Check the format and explode into $parts
  elseif (!ereg("^([0-9]{2})/([0-9]{2})/([0-9]{4})$", 
          $date, $parts)){
	$error_stat = 1; 	

//Set the message to tell the user the date is invalid
$date_message = '*Invalid date, must be DD/MM/YYYY format*';
}
    
  elseif (!checkdate($parts[2],$parts[1],$parts[3]))
  {
  $error_stat = 1; 
  
  //Set the message to tell the date is invalid for the month entered
$dob_message = '*Invalid dob, month must be between 1-12*';
}

elseif (intval($parts[3]) < 2008 || 
          intval($parts[3]) > intval(date("Y")))
  {
    
    $error_stat = 1; 

   //Set the message to tell the user the date is invalid for the year entered
$dob_message = '*Invalid dob, year must 2008 onwards*';
  }
  


//Then, only run the query if there were no errors (if $error_stat still equals 0) 
if ($error_stat == 0) { 
   mysql_query("INSERT INTO jobs (username, jobtitle, jobcatergory, joblocation, employmenttype, salary, date, educationallevel, description) VALUES ('$username', '$jobtitle', '$jobcatergory', '$joblocation', '$employmenttype', '$salary', '$date', '$educationallevel', '$description')"); 
echo "<h3>Registration Successful!</h3>"; 
   echo "<p>Thankyou, <b>$username</b>,registration was successful</p>"; 
   echo "<p>login.</p>";
  	echo "<a href=\"index2.php\">Login</a>";
  	
}
}


//Then, for the form, only show it if 1) the form hasn't been submitted yet OR 2) there is an error 
if (!isset($_POST['submit']) || $error_stat == 1) { 


?> 

<form method="post" class="addform" action="">  
<fieldset>  
<label for="cvtitle">Add a Job</label><fieldset> 
<p align="right"> </p>
</fieldset> 
<label for="username">Username:</label>  
<input readonly name="username" type="text" id="username" value="<?php echo $_SESSION["username"]; ?>" /><br />  
</fieldset>  

<hr class="hr_blue"/>

<fieldset>  
<label for="jobtitle">Job Title:</label>  
<input readonly name="jobtitle" type="text" id="jobtitle" value="<?php echo $account["jobtitle"]; ?>" /><br />   
</fieldset> 

<fieldset>    
<label for="jobcatergory">Job Catergory:</label><p></p>   
<select name="jobcatergory"> 
<option value="Please Select">Please Select</option> 
<?php 
  $jobcatergory_opts = array( 
    "Accountancy and Finance", 
    "Banking and Insurance", 
    "Construction", 
    "Customer Service", 
    "Engineering", 
    "Management",
    "Hotel and Catering", 
    "Information Technology",
    "Legal",
    "Marketing", 
    "Medical",
    "Retail",
    "Sales",
    "Secretarial",
    "Transport and Distribution",
    "Working from home",        
  ); 
  foreach($jobcatergory_opts as $opt){ 
    $selected = ($account["jobcatergory"]) == $opt ? " selected=true":""; 
    echo "<option value=\"" . $opt . "\"" . $selected . ">" . $opt . "</option>"; 
  } 
?> 
</select>
<?php echo "$jobcatergory_message";?> 
</fieldset>


<fieldset> 
<label for="joblocation">Location:</label> 
<p></p>
<select name="joblocation">
<option value="Please Select">Please Select</option>
<?php
  $joblocation_opts = array(
    "Co.Antrim",
    "Co.Armagh",
    "Co.Down",
    "Co.Fermanagh",
    "Co.Londonderry",
    "Co.Tyrone",
  );
  foreach($joblocation_opts as $opt){
    $selected = $_POST['joblocation'] == $opt ? " selected=true":"";
    print "<option value=\"{$opt}\"{$selected}>{$opt}</option>";
  }
?>
</select>
<?php echo "$joblocation_message";?><?php echo $error['joblocation']; ?></fieldset>  


<fieldset>  
<label for="employmenttype">Job Type:</label><p></p>  
<select name="employmenttype"> 
<option value="Please Select">Please Select</option> 
<?php 
  $employmenttype_opts = array( 
    "permanent fulltime", 
    "permanent parttime", 
    "temporary fulltime", 
    "temporary parttime", 
  ); 
  foreach($employmenttype_opts as $opt){ 
    $selected = ($account["employmenttype"]) == $opt ? " selected=true":""; 
    echo "<option value=\"" . $opt . "\"" . $selected . ">" . $opt . "</option>"; 
  } 
?> 
</select>
<?php echo "$employmenttype_message";?> 
</fieldset>


<fieldset>  
<label for="salary">Salary:</label>  
<input readonly name="salary" type="text" id="salary" value="<?php echo $account["salary"]; ?>" /><br />   
</fieldset>

<fieldset>  
<label for="date">Closing Date:</label>  
<input readonly name="date" type="text" id="date" value="<?php echo $account["date"]; ?>" /><br />   
</fieldset>  

<fieldset>  
<label for="educationallevel">Qualification Level Required:</label><p></p>   
<select name="educationallevel"> 
<option value="Please Select">Please Select</option> 
<?php 
  $educationallevel_opts = array( 
    "GCSE", 
    "A-Level", 
    "Third Level Certification", 
    "Third Level Diploma", 
    "Third Level Degree", 
    "Post Graduate Qualification",
    "Masters",
    "PHD",
    "Professional Qualification",
    "Part Professional Qualification",
    "Trade Qualification", 
  ); 
  foreach($educationallevel_opts as $opt){ 
    $selected = ($account["educationallevel"]) == $opt ? " selected=true":""; 
    echo "<option value=\"" . $opt . "\"" . $selected . ">" . $opt . "</option>"; 
  } 
?> 
</select>
</select>
<?php echo "$educationallevel_message";?><?php echo $error['educationallevel']; ?></</fieldset>

<hr class="hr_blue"/>

<fieldset> 
Job Description -<br /> 
</fieldset> 

<fieldset> 
<textarea rows="2" name="description" cols="20"><?php echo $account["description"]; ?></textarea><p></p> 
</fieldset> 

<p></p>
<fieldset> 
<p class="submit"><input type="submit" name="submit" value="Add Job" />

</fieldset>
</form>       

 

Link to comment
https://forums.phpfreaks.com/topic/91406-parse-error-unexpected-end-help/
Share on other sites

That usually means that you've left off a semi-colon, closing parenthesis or right curly brace.

 

Check your code carefully. You don't have a right closing curly brace for this line:

 

if (!isset($_POST['submit']) || $error_stat == 1) {

 

 

 

EDIT:

 

Good. Well done!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.