Q:

mysql_fetch_array convert into mysqli_

Im trying to rewrite mysql_ into mysqli_, but got 2 errors

mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given

and

mysqli_num_rows() expects parameter 1 to be mysqli_result,

why? Ive fixed mysql_query("SELECT...) into mysqli_query($db, "SELECT..) and all others
<?php
ob_start();
session_start();

include('config/configuration.php'); 

if($_POST['Login'])
 {
  $UserName=$_POST['username'];
  $Password=md5($_POST['password']); 

  $UserQuery=mysqli_query($db, "SELECT Id, UserName, FirstName, LastName, Level FROM users WHERE UserName='$UserName' AND Password='$Password' AND IsActive=1 and level >= 3");

    $UserDetails=mysqli_fetch_array($UserQuery);        

        if(mysqli_num_rows($UserQuery))
            {       
                    $_SESSION['UserName'] = $UserDetails['UserName'] . ' (' .  $UserDetails['FirstName'] . ' ' . $UserDetails['LastName'] . ')';
                    $_SESSION['UserId'] = $UserDetails['Id'];
                    $_SESSION['Level']  = $UserDetails['Level'];

                mysqli_query("UPDATE users SET NumberOfLogin = NumberOfLogin + 1, LastLoginDate = NOW() WHERE Id = " . $_SESSION['UserId'] . " ");

A:

Your query is failing. 
Try this to see the issue:
if (!$UserQuery) {
    echo "MySQLi Error: " . mysqli_error($con);
    die();
}

