title: Selecting a single field from a MySQL database for comparison of a variable
body: <p>I need to get 'groupLeader' field from the table 'groups' in the database and store it in a variable and then compare to the current logged in username but I get the error: </p>
  
  <blockquote>
    <p>Warning: mysql_numrows() expects parameter 1 to be resource, object given in /home/content/00/7923300/html/uber/tasks.php on line 31</p>
  </blockquote>
  
  <p>The code I currently have is this:</p>
  
  <pre><code>$sq = "SELECT * FROM groups WHERE groupID='".$groupID."'";
  $result=$db-&gt;query($sq);
  $num=mysql_numrows($result);
  $i=0;
  while ($i &lt; $num) {
      $gLeader=  mysql_result($result, $i, 'groupLeader');
      $i++;
  }
  if($_COOKIE['$username'] == $gLeader) {
      echo "User is leader.";
  }
  </code></pre>
  
  <p>Forgive me if this seems like a rather simple request. I'm new to php and working with databases.</p>
  
  <p>EDIT: Forgot to mention line 31 is the line that contains</p>
  
  <pre><code>$num=mysql_numrows($result);
  </code></pre>