title: Use variable in WHERE clause in PDO connection
body: <p>Hello I am using the followng code to update password, but I need to select which users should I update inside my SQL query there is a WHERE Clause if I put  number as id like 23 it is working but I wish this id to come from the POST method which is posting the id also from the form, here is the code in this version it is giving me an error: </p>
  
  <pre><code>`SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens`
  </code></pre>
  
  <p>and this is the code here     </p>
  
  <pre><code>   &lt;?php
  
  
  class Users {
  public $password = null;
  public $salt = "Zo4rU5Z1YyKJAASY0PT6EUg7BBYdlEhPaNLuxAwU8lqu1ElzHv0Ri7EM6irpx5w";
  
  public function __construct( $data = array() ) {
  if( isset( $data['id'] ) ) $this-&gt;id = stripslashes( strip_tags( $data['id'] ) );
  if( isset( $data['password'] ) ) $this-&gt;password = stripslashes( strip_tags( $data['password'] ) );
  }
  
  
  public function storeFormValues( $params ) {
  //store the parameters
  $this-&gt;__construct( $params );
  }
  
  
  public function register() {
  $correct = false;
  try {
  $con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );
  $con-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
  $sql = "Update users SET password = :password WHERE userID = :id";
  
  $stmt = $con-&gt;prepare( $sql );
  $stmt-&gt;bindValue( "password", hash("sha256", $this-&gt;password . $this-&gt;salt), PDO::PARAM_STR );
  $stmt-&gt;execute();
  
  
  
   return "Registration Successful &lt;br/&gt; &lt;a href='index.php'&gt;Login Now&lt;/a&gt;";
         }catch( PDOException $e ) {
                   return $e-&gt;getMessage();
         }
  }
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>So the question is how to put the posted WHERE userID= :id;</p>