I have searched about problem but i can't solve this code, I see this error :
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\Program Files\EasyPHP\www\test\index.php on line 13
and this is my PHP codes :
<?php
$user_ip = $_SERVER['REMOTE_ADDR'];
function ip_exists($ip) {
    $con = mysqli_connect("localhost","root","","ok");
    if (mysqli_connect_errno()) {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
    global $user_ip;
    $query = "SELECT ip FROM hits_ip WHERE ip = $user_ip";
    $query_run = mysqli_query($con,$query);
    $query_num_rows = mysqli_num_rows($query_run);
    if ($query_num_rows==0) {
        return false ; 
    }
    else if($query_num_rows>=1) {
        return true ;
    }
}
if (ip_exists($user_ip)) {
    echo "EXIST";
}
else {
echo "NO ex";
}
?> 
What is the problem and what should i do ?
I want to use mysqli .
 
     
     
     
    