title: Unable to Fetch_Assoc() of Prepared Statement in PHP, If Fetch is Used num_rows becomes Zero
body: <pre><code>public function Login($username, $pass){
      if(!empty($username) &amp;&amp; !empty($pass)){
          $user = $this-&gt;link-&gt;prepare("SELECT username, pass FROM users WHERE username=? AND pass=?");
          $user-&gt;bind_param("ss", $username, $pass);
          $user-&gt;execute();
  
          $row=$user-&gt;fetch_assoc();
  
          If($user-&gt;num_rows==1){         
              session_start();
              $_SESSION['name']=$row['username'];
              $_SESSION['name']=true;
              header("Location: admin.php");                  
          }else{
              echo "Invalid Username and Password";   
          }   
  
      }else{
          echo "Empty Login Details";
      }
  }
  </code></pre>
  
  <p>The Test for <code>num_row = 0</code> because the result is now in associate array,
  When i used <code>Fetch()</code>, the <code>num_rows</code> was correct to be 1, but i can not access the array to assign <code>$row['username']</code> to Session Variable.</p>