title: Why I am getting number of bound variables does not match number of tokens error message?
body: <p>I am creating a dynamic function to insert data to the database using PHP PDO. </p>
  
  <p>Here is the function in the <code>Database</code> Class. </p>
  
  <pre><code>public function insert ( $table, $feilds = array() ) {
  
      $key    = array_keys($feilds);
      $column = implode(',', $key);
  
      $ques   = array();
  
      foreach ($feilds as $value) {
          $ques[] = " ?";
      }
  
      $ques = implode(', ', $ques);   
  
      $stmt = $this-&gt;_pdo-&gt;prepare("INSERT INTO $table( $column ) VALUES ( $ques )");
  
      $x=1;       
      foreach ($feilds as $key =&gt; $value) {
          $stmt-&gt;bindParam($x, $var);
          $var =  $value;
          $stmt-&gt;execute();           
          $x++;
      }       
  }
  </code></pre>
  
  <p>I am inserting data like this: </p>
  
  <pre><code>$data = array(
      'b_title'   =&gt;  'My blog title', 
      'b_des'     =&gt;  'My blog description',
  );
  $database-&gt;insert('blog', $data);
  </code></pre>
  
  <p>But when I run this query it's saying </p>
  
  <blockquote>
    <p>Invalid parameter number: number of bound variables does not match
    number of token</p>
  </blockquote>
  
  <p>I don't understand where the bound variable and token is not matched! How can I solve it? </p>
  
  <p>Thanks. </p>