title: Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
body: <p>I'm trying to follow this tutorial on <a href="http://webdevelopingcat.com/creating-a-registration-page-with-php-and-pdo/" rel="nofollow">http://webdevelopingcat.com/creating-a-registration-page-with-php-and-pdo/</a> but change it a little (well just remove address). However after correcting some errors myself I'm quite stuck on this one. </p>
  
  <p>My HTML and PHP code is as follows;</p>
  
  <pre><code>&lt;?php
    if ( empty( $_POST ) ) {
  ?&gt;
  
  &lt;h1&gt;PCReviews - Registration&lt;/h1&gt;
  &lt;form name="registration" action="registration" method="POST"&gt;
    &lt;label for 'username'&gt;Username: &lt;/label&gt;
    &lt;input type="text" name="username"/&gt;
    &lt;label for 'password'&gt;Password: &lt;/label&gt;
    &lt;input type="password" name="password"/&gt;
    &lt;label for 'first_name'&gt;First name: &lt;/label&gt;
    &lt;input type="text" name="first_name"/&gt;
    &lt;label for 'surname'&gt;Surname: &lt;/label&gt;
    &lt;input type="text" name="surname"/&gt;
    &lt;label for 'email'&gt;Email: &lt;/label&gt;
    &lt;input type="text" name="email"/&gt;
    &lt;br/&gt;
    &lt;button type="submit"&gt;Register!&lt;/button&gt;
   &lt;/form&gt;
  
  &lt;?php
  } else {$conn = new PDO("mysql:host=localhost;dbname=XXXX",'XXXX','XXXXX');
    print_r ( '&lt;p&gt;Registration Succesfull!&lt;/p&gt;' );
  
  $form = $_POST;
  $username = $form[ 'username' ];
  $password = $form[ 'password' ];
  $first_name = $form[ 'first_name' ];
  $surname = $form[ 'surname' ];
  $email = $form[ 'email' ];
  $sql = "INSERT INTO UserAccounts ( username, password, first_name, surname, email ) VALUES ( :username, :password, :first_Name, :surname, :email )";
  
  $query = $conn-&gt;prepare( $sql );
  $query-&gt;execute( array( ':username'=&gt;$username, ':password'=&gt;$password, ':first_name'=&gt;$first_name, ':surname'=&gt;$surname,':email'=&gt;$email ) );
  
  $result = $query-&gt;execute( array( ':username'=&gt;$username, ':password'=&gt;$password, ':first_name'=&gt;$first_name, ':surname'=&gt;$surname, ':email'=&gt;$email ) );
  
  if ( $result ){
    echo "&lt;p&gt;Thank you. You have been registered&lt;/p&gt;";
  } else {
    echo "&lt;p&gt;Sorry, there has been a problem inserting your details..&lt;/p&gt;";
  }
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>However I receive an error as follows;</p>
  
  <blockquote>
    <p>Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in /home/4328054/public_html/registration.php on line 34<br>
    Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in /home/4328054/public_html/registration.php on line 36</p>
  </blockquote>
  
  <p>Thank you :)</p>