title: How can I convert this working mysql statement to PDO effectively?
body: <p>I'm trying to convert to using PDO, but can't seem to get results from my PDO while loop.</p>
  
  <p>This mysql statement gives me results:</p>
  
  <pre><code>$q = mysql_query("SELECT * FROM artist ORDER BY artist ASC");
  while ($row = mysql_fetch_array($q)) {
    $theartist .= '&lt;option value="'.($row['artist_id']).'"&gt;'.($row['artist'])."&lt;/option&gt;";
  }    
  </code></pre>
  
  <p>PDO database connection (that appears to work)</p>
  
  <pre><code>//the below isn't throwing any errors
  $host='localhost';
  $dbname='james_test';
  $user='test';
  $pass='testpass';
  
  try {
    # MySQL with PDO_MYSQL
    $DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
  }
  catch(PDOException $e) {
      echo $e-&gt;getMessage();
  }
  </code></pre>
  
  <p>This PDO statement does not give me any results:</p>
  
  <pre><code>$query = $DBH-&gt;prepare("SELECT * FROM artist ORDER BY artist ASC");
  while($row = $query-&gt;fetch(PDO::FETCH_ASSOC)) {
      $theartist .= '&lt;option value="'.($row['artist_id']).'"&gt;'.($row['artist'])."&lt;/option&gt;";
  }
  </code></pre>