title: Call to a member function fetch_assoc() on a non-object
body: <p>Here's my function: </p>
  
  <pre><code>function get_fname($un){
  
  $registerquery = $this-&gt;conn-&gt;query("SELECT f_name FROM tz_members WHERE 
                       usr='".$un."'");
  
  while ($row = $registerquery-&gt;fetch_assoc()) { 
      return $fname = $row[$un];
      }
  }
  </code></pre>
  
  <h2>Edit:</h2>
  
  <p>I chose to answer my own question because it has an editor.</p>
  
  <p>@Mark Baker:</p>
  
  <pre><code>&lt;?php
      require_once 'Mysql.php'; 
      $mysql = new Mysql(); 
  
  ?&gt;
  &lt;html&gt;
    &lt;head&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;h4&gt;&lt;?php echo $mysql-&gt;get_fname("joann"); ?&gt;&lt;/h4&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>That's how I am doing it...</p>