title: Fatal error Invalid parameter number: mixed named and positional parameters
body: <p>I'm getting a Fatal error when I try to add <code>$stmt-&gt;bindParam(':username', $username, PDO::PARAM_STR);</code> to my script. Below is just part of my script. What I'm trying to do is get it to use the session username along with id. If I take out the <code>username = :username</code> and the <code>$stmt-&gt;bindParam(':username', $username, PDO::PARAM_STR);</code> it will work fine.</p>
  
  <p>Fatal error I'm getting:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: mixed named and positional parameters' in /home/www/test.php:7 Stack trace: #0 /home/www/test.php(7): PDOStatement->execute() #1 {main} thrown in /home/www/test.php on line 7</p>
  </blockquote>
  
  <pre><code>    $action = isset($_GET['action']) ? $_GET['action']: "";
  if($action=='delete'){
  $username    = $_SESSION['user']['username'];&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;I ADD THIS LINE
  $query = "DELETE FROM hostingpackage WHERE  username = :username And id = ?";
          $stmt = $db-&gt;prepare($query);
          $stmt-&gt;bindParam(1, $_GET['id']);
          $stmt-&gt;bindParam(':username', $username, PDO::PARAM_STR);&lt;&lt;&lt;&lt;I ADD THIS LINE
          $result = $stmt-&gt;execute();
          header("Location: test.php");
          die("Redirecting to test.php");
         }
  </code></pre>