title: mysqli fetching multiple rows
body: <p>I am trying to convert over to mysqli and as expected, I am running into difficulties.</p>
  
  <p>I have created a login script as follow, which works and I think is correct. (I know the passwords need to be hashed, I just want to get it up and running first)</p>
  
  <pre><code>//  POST variables
  $username = ($_POST['username']);
  $password = ($_POST['password']);
  
  //Input Validations
  if($username == '') {
      $errmsg_arr[] = 'Username required';
      $errflag = true;
  }
  if($password == '') {
      $errmsg_arr[] = 'Password required';
      $errflag = true;
  }
  
  //If there are input validations, redirect back to the login form
  if($errflag) {
      $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
      session_write_close();
      header("location: logon.php");
      exit();
  }
  
  //prepared statements
  
  if ($stmt = $mysqli-&gt;prepare("SELECT username, password FROM auth WHERE username='$username' AND password='$password'")) {
  $stmt-&gt;execute();
  
  /* bind variables to prepared statement */
  $stmt-&gt;bind_result($user, $pass);
  
  /* fetch values */
  $stmt-&gt;fetch();
  if ($user == $username &amp;&amp; $pass == $password)
  {
      printf("Welcome %s", $user);
  }
  else
  {
      printf("Login failed");
  }
  
  
  /* close statement */
  $stmt-&gt;close();
  }
  /* close connection */
  $mysqli-&gt;close();
  
  ?&gt;
  </code></pre>
  
  <p>I would like to set my session variables if the login passes, previously with mysqll I did the following </p>
  
  <pre><code>$qry="SELECT * FROM auth WHERE username='$username' AND password='$password'";
  $result=mysql_query($qry);
  
  //Check whether the query was successful or not
  if($result) {
      if(mysql_num_rows($result) &gt; 0) {
          //Login Successful
          session_regenerate_id();
          //Set session variables
          $member = mysql_fetch_assoc($result);
          $_SESSION['SESS_MEMBER_ID'] = $member['ID'];
          $_SESSION['SESS_USERNAME'] = $member['username'];
          $_SESSION['SESS_FIRST_NAME'] = $member['fname'];
          $_SESSION['SESS_PASSWORD'] = $member['password'];
          $_SESSION['SESS_AUTH_LEVEL'] = $member['auth_level'];
          session_write_close();
          header("location: index");
          exit();
      }else {
          //Login failed
          $errmsg_arr[] = 'user name or password not found';
          $errflag = true;
          if($errflag) {
              $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
              session_write_close();
              header("location: logon.php");
              exit();
  </code></pre>
  
  <p>I think my problem is "$member = mysql_fetch_assoc($result);" how do I do this in mysqli ? As my prepared statement is only binding the username and password, previously I used a SELECT * FROM</p>
  
  <p>Thanks</p>