title: PHP function doesn't pass argument to PDO query
body: <p>Why the 2nd argument isn't passed to the query?</p>
  
  <pre><code>function LikesPastMonth($nMonth, $pid)
      {
          if($nMonth !== 0) {
              $n = $nMonth*-1-1;      
          } else {
              $n = -1;
          }
          $bdd = new PDO('mysql:host=localhost;dbname=xx', 'xx', 'xx', array(PDO::ATTR_PERSISTENT =&gt; true));
          $req = $bdd-&gt;prepare('SELECT * FROM likes WHERE thedate = DATE_ADD( DATE_ADD( LAST_DAY( CURDATE( ) ) , INTERVAL 1 DAY ) , INTERVAL '.$n.' MONTH ) AND pid = ?');
          $req-&gt;execute(array($pid));
          $result = $req-&gt;rowcount();
          if(!$result) {
              $result = 0;
          }
          return $result;
      }
  </code></pre>
  
  <p>Using a constant instead of arg and not preparing the query works.</p>
  
  <pre><code>define('pid','777');
  $req = $bdd-&gt;query('SELECT * FROM likes WHERE thedate = DATE_ADD( DATE_ADD( LAST_DAY( CURDATE( ) ) , INTERVAL 1 DAY ) , INTERVAL '.$n.' MONTH ) AND pid = "'.pid.'"')-&gt;fetchColumn();
  </code></pre>
  
  <p>Putting the arg directly into the query doesn't work (2 examples of how i did try):</p>
  
  <p>1:</p>
  
  <pre><code>$req = $bdd-&gt;query('SELECT * FROM likes WHERE thedate = DATE_ADD( DATE_ADD( LAST_DAY( CURDATE( ) ) , INTERVAL 1 DAY ) , INTERVAL '.$n.' MONTH ) AND pid = "'.$pid.'"')-&gt;fetchColumn();
  </code></pre>
  
  <p>2:</p>
  
  <pre><code>$req = $bdd-&gt;query('SELECT * FROM likes WHERE thedate = DATE_ADD( DATE_ADD( LAST_DAY( CURDATE( ) ) , INTERVAL 1 DAY ) , INTERVAL '.$n.' MONTH ) AND pid = '.$pid.'')-&gt;fetchColumn();
  </code></pre>