title: PHP script seems to return null using PDO on SQL statement with aggregate but works in MySQL workbench
body: <p>I have been using this PHP script with PDO for other pages and works fine so I suspect there is something wrong with my SQL but copying it into MySQL workbench returns me three rows as I expect like so:<br/></p>
  
  <blockquote>
    <p>voteCount, mphoto<br/>
    '3', '170066'<br/>
    '1', '168304'<br/>
    '1', '169126'<br/></p>
  </blockquote>
  
  <p>I am just learning to use aggregate functions (COUNT in particular) so I am suspicious of that being my problem but am clueless to what is going wrong.  I am also not seeing an echo of any PDO error that should be caught so I think it is not that.  Here is my code:</p>
  
  <pre><code>$winnerstmt = queryWinner('mphoto');
  echo "here is our var dump:".var_dump($winnerstmt);
  
  function queryWinner($category)
  {
      $sql = "SELECT COUNT($category) AS voteCount,$category 
              FROM studentVote WHERE $category!=111111 
              GROUP BY $category ORDER BY voteCount DESC LIMIT 3;";
      // TODO following echo is for debug
      echo $sql;
      databaseQuery($sql); 
  }
  
  function databaseQuery($sql)
  {
      $hostname="hidden from post";
      $dbname = "hidden from post";
      $username = "hidden from post";
      $passwd = "hidden from post";
      $row = '';
      try {
          $db = new PDO("mysql:host=$hostname;dbname=$dbname;charset=utf8",
                    $username,
                  $passwd);
          $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          $db-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false); 
  
          $stmt = $db-&gt;query($sql);
          echo "We made it past the db query without an error";
          return $stmt; 
  
      } catch(PDOException $e) {
          echo "we Received a Database error";
          echo $e-&gt;getMessage();
          return $e;
      }
  }
  </code></pre>
  
  <p>The output I am getting is this:<br/>
  SELECT COUNT(mphoto) AS voteCount,mphoto FROM studentVote WHERE mphoto!=111111 GROUP BY mphoto ORDER BY voteCount DESC LIMIT 3;<br/>
  We made it past the db query without an error<br/>
  null</p>