title: Get data from multiple table at $_SESSION PHP
body: <p>currently I want to get two different data from two tables when users login to the system. The entitle table is "user","user_staff" and "user_group". But when the user enter its username and password and submit it prompt <strong><em>"Fatal error: Call to a member function fetch_array() on a non-object in C:\xampp\htdocs\auditsystem\index.php on line 26"</em></strong></p>
  
  <p>Below are the code:</p>
  
  <pre><code>if($username!= "" &amp;&amp; $password != "")
  {
  //INNER JOIN user_group_module_role ON user.user_group_module_role_id = user_group_module_role.id
      $result =  $db-&gt;query("SELECT * FROM user 
                              INNER JOIN user_staff ON user.user_staff_id = user_staff.id
                              WHERE username = '$username' AND password = '$password'"); 
  
  
  
      if($result-&gt;num_rows == 1)
      {
          $validate = $result-&gt;fetch_assoc();
  
          $query1 = "SELECT * FROM usergroup WHERE id = $validate[user_group_id]";
          $result1 = $db-&gt;query($query1);
          $row1 = $result1-&gt;fetch_array();
          //change here for the authority 
          $_SESSION['user_staff'] = $validate['displayname'];
          $_SESSION['usergroup'] = $row1['user_group_type'];
          echo "&lt;script language='javascript'&gt;window.location='panel.php'&lt;/script&gt;"; 
      }
      else
      {
          echo "&lt;script&gt;alert('Sorry, wrong username and password please check.')&lt;/script&gt;";
      }
  }
  </code></pre>