title: ERROR: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
body: <p>saw this was an error with incorrect binding (searching stackoverflow), but it looks like I have all variables bound and no typos.... am I missing the obvious here?</p>
  
  <pre><code>function connect () {
  global $pdo;
  try {
      $pdo = new PDO("mysql:host=localhost;dbname=test", "root", "root");
      $pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  } catch(PDOException $e) {
      echo 'ERROR: ' . $e-&gt;getMessage();
    }
  }
  
  function getPhotos ($status = 0, $type = null, $session = null, $name = null) {
  global $pdo;
  try {
      $sql = 'SELECT * FROM images WHERE 1=1';
  
      //Status Filter Query
      $sql .=' AND status = :status';
  
      //Type Filter Query
      if (!is_null($type)) {
          $sql .=' AND type = :type';
      }
  
      // Session Filter Query
      if (!is_null($session)) {
          $sql .=' AND session = :session';
      }
  
      // Twitter Handle Filter Query
      if (!is_null($name)) {
          $sql .=' AND handle = :name';
      }
  
      //Prepare The Query
      $stmt = $pdo-&gt;prepare($sql);
  
      //Fire The Lasers
      $stmt-&gt;execute(array(':status' =&gt; $status, ':type' =&gt; $type, ':session' =&gt; $session, ':name' =&gt; $name));
  
      //Grab 
      return $stmt-&gt;fetchAll();
  </code></pre>