title: Count number of MySQL rows
body: <p>Im trying to count the number of rows in a MySQL database and report that number using PHP. I've read all the documentation and I think this piece of code should be working but no matter what I try, it fails.</p>
  
  <pre><code>&lt;?php
  session_start();
  if ( isset($_SESSION['username']) ) {
      $username = $_SESSION['username'];
      $q = "SELECT * FROM messages WHERE recepiants='$username' AND readcheck='T'";
      $count = mysql_num_rows($q);
  ?&gt;
  &lt;div class="user_info"&gt;Logged in as &lt;?php echo $username; ?&gt; | &lt;a href="admin.php"&gt;Add a post&lt;/a&gt; | &lt;a href="experiment.php"&gt;View Posts&lt;/a&gt; | &lt;a href="inbox.php"&gt;Message Center &lt;?php echo $count; ?&gt; &lt;/a&gt; | &lt;a href="logout.php"&gt;Log Out&lt;/a&gt;&lt;/div&gt;
  &lt;?php } else {?&gt; 
  </code></pre>
  
  <p>The script successfully reports <code>$username</code> but <code>$count</code> doesn't return a number. Any ideas? Am I missing a bracket or semi-colon somewhere?</p>