mysqli_num_rows() expects parameter 1 to be mysqli_result ERROR in php

Asslam.o.alaikum;

I could not be able to understand this error. I have googled it but it did not solve my problem. I am newbie to php. Here my code check it and help! Any help would be appreciated. Thanks and regards.

<?php
include("connect.php");
if(isset($_POST['login'])) {
	
	$user_name = $_POST['user_name'];
	$user_pass = $_POST['user_pass'];
	
	$login_query = "SELECT * FROM admin_login where user_name='$user_name' AND use_password='$user_pass'";
	
	$run = mysqli_query($con);
	
	if(mysqli_num_rows($run)>0) {
		
		$_SESSION['user_name']=$user_name;
		echo "<script>widnow.open('index.php','_self')</script>";
		
	}
	else {
		
	echo "<script>alert('User Name or Password is incorrect')</script>";	
		
		
	}
	
}

?>

Option 1

check... connect.php (there may be a database connection error)

Option 2

check... $run = mysqli_query($con);

Last Option (if all fails, know your error)

The problem is your query returned false meaning there was an error in your query. After your query you could do the following:

if (!$result) {
die(mysqli_error($link));
}

[quote=“shafiq, post:2, topic:22000”]

Option 1

check... connect.php (there may be a database connection error)

Option 2

check... $run = mysqli_query($con);

Last Option (if all fails, know your error)

The problem is your query returned false meaning there was an error in your query. After your query you could do the following:

if (!$result) {

die(mysqli_error($link));

}

[/quote]

Thanks for the Help. Actually I figured it out. Actually in my $login_query i mistakenly wrote use_password instead of user_password. :)