title: Fatal error: Call to undefined function fetch_assoc() What Gives?
body: <p>Im trying to display users from the database on the page after login but i keep getting an error message:</p>
  
  <p>Fatal error: Call to undefined function fetch_assoc()</p>
  
  <p>here is the code:</p>
  
  <pre><code>    &lt;?php
  session_start(); ?&gt;
  
  &lt;link rel="stylesheet" href="form.css"&gt;
  &lt;div class="body content"&gt;
  
      &lt;div class="welcome"&gt;
          &lt;div class="alert alert-success"&gt;&lt;?= $_SESSION['message'] ?&gt;&lt;/div&gt;
          &lt;img src="&lt;?= $_SESSION['avatar'] ?&gt;"&gt;&lt;br /&gt;
          Welcome &lt;span class="user"&gt;&lt;?= $_SESSION['username'] ?&gt;&lt;/span&gt;
  
          &lt;?php
          $mysqli = new mysqli("localhost","user","password","database");
          //Select queries return a resultset
          $sql = "SELECT username, avatar FROM users";
          $result = $mysqli-&gt;query($sql); //$result = mysqli_result object
          //var_dump($result);
          ?&gt;
  
          &lt;div id='registered'&gt;
          &lt;span&gt;All registered users:&lt;/span&gt;
  
          &lt;?php
          //while($row = $result-&gt;fetch_assoc()){ //returns associative array of fetched row
           while($row = fetch_assoc($result)){ //returns associative array of fetched row
              //echo '&lt;pre&gt;';
              //print_r($row);
              //echo '&lt;/pre&gt;';
              echo "&lt;div class='userlist'&gt;&lt;span&gt;$row[username]&lt;/span&gt;";
              echo "&lt;img src='$row[avatar]'&gt;&lt;/div&gt;";
          }
          ?&gt;  
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>