title: Call to a member function fetch() on a non-object in
body: <p>I'm trying to make a select in php with pdo.<br/>
  It's working with a lot of req but not when I'm using a like, example :<br/></p>
  
  <p><strong>Query:</strong></p>
  
  <pre><code>SELECT * FROM projets WHERE `identifiantProjetRattachement` LIKE "%PC13287%" ORDER BY "identifiantProjetDSR"
  </code></pre>
  
  <p>This is my php code :</p>
  
  <pre><code>&lt;?php
      function requette($requette,$table)
      {
          $bdd = new PDO('mysql:host=localhost;dbname=spb', 'root', '');
          $sql =  "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='$table';";
          $req = $bdd-&gt;query($sql);
  
          $titres = array();
  
          while($resultat = $req-&gt;fetch())
          {
             array_push($titres,$resultat['COLUMN_NAME']);
          }
  
          // ON A LES TITRES DONC ON PASSE AU CONTENU
          $sql =  $requette;
          $req = $bdd-&gt;query($sql);
  
          $retour = "";
          $cpt = 0;
          $nbLigne = 0;
  
          while($resultat = $req-&gt;fetch())
          {
             $nbLigne++;
             $retour .= "&lt;tr&gt;&lt;td class='boutonTouteLaCase' onclick='surlignerLigneProjets(this);'&gt;&lt;/td&gt;&lt;td&gt;$nbLigne&lt;/td&gt;";
             for($cpt=0;$cpt&lt;count($titres);$cpt++)
             {
               if($titres[$cpt] != "id")
                 $retour .= "&lt;td&gt;".utf8_encode($resultat[$titres[$cpt]])."&lt;/td&gt;";
             }
  
             $retour .= "&lt;/tr&gt;";
          }
          echo $retour;   
        }
  
      $requette = htmlentities($_POST['requette']);
      $table = htmlentities($_POST['table']);
  
      echo $requette."&lt;br/&gt;";
      echo $table."&lt;br/&gt;";
  
       echo requette($requette,$table);?&gt;
  </code></pre>
  
  <p>Do you think it's an accent problem ? Or a problem due to a ' ?
  <br/>
  PS : This req works on phpmyadmin.<br/>
  Thanks for all.</p>