-2

I am very new to php and am working on an assignment. I have pretty much copied the same format as the example our teacher gave us (I just changed the variable names) but I am getting an unexpected 'fnameempty' (T_STRING), expecting ']' I'm not sure why this is happening.. Can you please help?

Here is my code :

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

   $errors =array();

  $fname = $_POST["firstname"];
  $fname = trim($fname);
  $fname = strtolower($fname);
  $fname = ucfirst($fname);
  $lname = $_POST["lastname"];
  $lname = trim($lname);
  $lname = strtolower($lname);
  $lname = ucfirst($lname);
  $hworked = $_POST["hoursworked"];
  $hwage = $_POST["hourlywage"];

//Validating empty elements

  if(empty($fname)) {
    $errors['fnameempty'] = "*";
  }

Thank you!

devpro
  • 16,184
  • 3
  • 27
  • 38
Jthunter24
  • 57
  • 1
  • 1
  • 7

1 Answers1

1

You've forgotten a closing ' in the $_POST array.

if(isset($_POST['calculate])) {
Lando
  • 419
  • 3
  • 8