title: mysqli conversion fetch query
body: <p>How can i convert this statement into mysqli. i tried converting it but is not working. what am i missing. I want to connect to a login form. </p>
  
  <p>This is the code i converted.</p>
  
  <pre><code>&lt;?php
  include('admin/dbcon.php');
          session_start();
          $username = $_POST['username'];
          $password = $_POST['password'];
  
          /* teacher */
          $query_teacher = mysql_query("SELECT * FROM teacher WHERE username='$username' AND password='$password'")or die(mysql_error());
          $num_row_teacher = mysql_num_rows($query_teacher);
          $row_teahcer = mysql_fetch_array($query_teacher);
  
          /* admin */
          $query_admin = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'")or die(mysql_error());
          $num_row_admin = mysql_num_rows($query_admin);
          $row_admin = mysql_fetch_array($query_admin);
  
  
           if ($num_row_teacher &gt; 0){
          $_SESSION['id']=$row_teahcer['teacher_id'];
          echo 'true';
  
          }else if ($num_row_admin &gt; 0){
          $_SESSION['id']=$row_admin['user_id'];
          echo 'true_admin';
  
           }else{ 
                  echo 'false';
          }   
  
          ?&gt;
  </code></pre>
  
  <p>This is the converted mysqli but i cannot still log on am i missing something. I will be very grateful if you can help me solve this. </p>
  
  <pre><code>&lt;?php
  
  // establishing the MySQLi connection
  
  
  
  $con = mysqli_connect("localhost","root","","retreat");
  
  if (mysqli_connect_errno())
  
  {
  
  echo "MySQLi Connection was not established: " . mysqli_connect_error();
  
  }
  
  // checking the user
          session_start();
  
          $username = mysqli_real_escape_string($con,$_POST['username'];
          $password = mysqli_real_escape_string($con,$_POST['password'];
  
  
          /* teacher */
  
  
  
          $query_teacher = "SELECT * FROM teacher WHERE username='$username' AND password='$password'";
  
          $num_row_teacher = mysqli_query($con,$query_teacher);
  
          $row_teahcer = mysqli_num_rows($num_row_teacher);
  
          /* admin */
          $query_admin = "SELECT * FROM users WHERE username='$username' AND password='$password'";
  
          $num_row_admin = mysqli_query($con,$query_admin);
          $row_admin = mysqli_num_rows($num_row_admin);
  
  
           if ($row_teahcer &gt; 0){
               //$_SESSION['user_email']=$email;
          $_SESSION['']=$row_teacher['teacher_id'];
          echo 'true';
  
          }else if ($num_row_admin &gt; 0){
          $_SESSION['id']=$row_admin['user_id'];
          echo 'true_admin';
  
           }else{ 
                  echo 'false';
          }   
  
          ?&gt;
  </code></pre>