title: I keep on getting an error "syntax error, unexpected 'catch' (T_CATCH) "
body: <p>I'm a beginner at PHP, I'm attempting a website to sign up and etc. I keep in getting an error "unexpected 'catch' (T_CATCH) in C:\wamp\www\ass\signup.php on line 67" whenever I click submit on my sign up form (It's in a different html form). The following is the code for my php file that's called when I hit submit on the html form. Please help and very sorry if there are a lot of rookie mistakes here. As I said, I'm a beginner.</p>
  
  <pre><code>    &lt;?php
  
  include('connect.php');
  
  $username =$_POST['username'];
  $firstname = $_Post['firstName'];
  $lastname = $_Post['lastName'];
  $emailadd = $_POST['emailAdd'];
  $gender = $_POST['gender'];
  $userpassword = $_Post['userPassword'];
  $dayofbirth = $_POST['dayOfBirth'];
  $monthofbirth = $_POST['monthOfBirth'];
  $yearofbirth = $_POST['yearOfBirth'];
  $profiledesc = $_POST['profileDesc'];
  
  $date = $_POST['yearOfBirth'] . '-' . $_POST['monthOfBirth'] . '-' . $_POST['dayOfBirth'];
  
  
      try {
      $host = "localhost";
      $username = "root";
      $password = "";
      $database = "users";
      $dsn = "mysql:host=$host;dbname=$database";
  
      $conn = new PDO( $dsn, $username, $password );
      $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
      $sql = "INSERT INTO userProfile("
      . "username, firstName, lastName, emailAdd, gender, userPassword, birthday, profileDesc" 
      . " ) VALUES (" 
      . "'" . $lastname . "',"
      . "'" . $firstname . "',"
      . "'" . $emailadd . "',"
      . "'" . $gender ."';"
      . "'" . $userpassword ."';"
      . "'" . $date ."';"
      . "'" . $profiledesc ."';";
  
  
      $conn-&gt;query($sql);
  
      $sql = "SELECT * FROM users";
      $users = $conn-query($sql);
      echo '&lt;table&gt;';
      echo '&lt;tr&gt;';
      echo '&lt;th&gt;First Name&lt;/th&gt;
            &lt;th&gt;Last Name&lt;/th&gt;
            &lt;th&gt;Email Address&lt;/th&gt;
            &lt;th&gt;Gender&lt;/th&gt;';
      echo '&lt;tr&gt;';
      foreach ($users as $users) {
      echo '&lt;tr&gt;';
      echo '  &lt;td&gt;' . $users['firstName'] . '&lt;/td&gt;';
      echo '  &lt;td&gt;' . $users['lastName'] . '&lt;/td&gt;';
      echo '  &lt;td&gt;' . $users['emailAdd'] . '&lt;/td&gt;';
      echo '  &lt;td&gt;' . $users['gender'] . '&lt;/td&gt;';
      echo '  &lt;/tr&gt; ';
  
  }
  
  echo '&lt;/table&gt;';
  
          $conn = null;
  
      catch (PDOException $e) {
          $conn = null;
          exit("Connection failed: " . $e-&gt;getMessage());
      }
  ?&gt;
  </code></pre>