title: PHP Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound
body: <p>I'm trying to create a form that when submitted will update a database that contains user's information. I am using PDO and transactions but keep getting the following error when the form is submitted </p>
  
  <pre><code>PHP Warning:  PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in /var/www/html/resources/memfuncs.php on line 75
  </code></pre>
  
  <p>Here is my code:</p>
  
  <p><strong>Settings.php</strong></p>
  
  <pre><code>if(isset($_POST['username'])){
      $id = $_SESSION['id'];
      $username = $_POST['username'];
      $first_name = $_POST['first_name'];
      $last_name = $_POST['last_name'];
      $email = $_POST['email'];
      $password1 = $_POST['password1'];
      $password2 = $_POST['password2'];
  
      if ($password1 === $password2){
      updatesettings($id, $username, $first_name, $last_name, $email, $password);
      }
  }
  </code></pre>
  
  <p>I haven't included the HTML for the form, although it is also in the above file.</p>
  
  <p><strong>memfuncs.php</strong></p>
  
  <pre><code>function updatesettings($id, $username, $first_name, $last_name, $email){
      global $db;
  
      $db-&gt;beginTransaction();
  
      try {
          // UPDATE USERNAME
          $st2 = $db-&gt;prepare("UPDATE users SET username = :username WHERE id = :id");
          $st2-&gt;execute();
          $st2-&gt;bindParam (":username", $username, PDO::PARAM_STR);
          $st2-&gt;bindParam (":id", $id, PDO::PARAM_INT);
          //UPDATE FIRST + LAST NAME
          $st = $db-&gt;prepare("UPDATE users SET first_name = :first_name AND last_name = :last_name WHERE id = :id");
          $st-&gt;execute();
          $st-&gt;bindParam (":first_name", $first_name, PDO::PARAM_STR);
          $st-&gt;bindParam (":last_name", $last_name, PDO::PARAM_STR);
          $st-&gt;bindParam (":id", $id, PDO::PARAM_INT);
          // UPDATE Email
          $st3 = $db-&gt;prepare("UPDATE users SET email = :email WHERE id = :id");
          $st3-&gt;execute();
          $st3-&gt;bindParam(":email", $email, PDO::PARAM_STR);
          $st3-&gt;bindParam(":id", $id, PDO::PARAM_INT);
          // COMMIT CHANGES
          $db-&gt;commit();
      } catch (Exception $error){
          $db-&gt;rollBack();
          echo "Failed: " . $error-&gt;getMessage();
      }
  
  }   
  </code></pre>
  
  <p>What am I doing wrong?</p>