-6
<?php 
include("includes/connect.php"); 
if(isset($_POST['login'])){ 
$user_name = $_POST['user_name']; 
$user_pass = $_POST['user_pass'];  
$login_query = "SELECT * all from admin_login where user_name='$user_name' AND user_password='$user_pass' ";  
$run = mysql_query($login_query);  
if(mysql_num_rows($run)>0){     
$_SESSION['user_name']=$user_name;  
echo "<script>window.open('index.php','_self')</script>";  
} else {  
echo "<script>alert('User Name or Password is incorrect!')</script>";    } }    ?>

This error shows that

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\malala\admin\login.php on line 8

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 2
    pls use code formatting... – DZDomi Feb 28 '16 at 10:54
  • 1. `session_start();`missing.2. don't use `mysql_*` use `mysqli_*` or `PDO`. 3. ` – Alive to die - Anant Feb 28 '16 at 10:59
  • 1
    `SELECT * from admin_login where user_name='$user_name' AND user_password='$user_pass'` use this – devpro Feb 28 '16 at 11:04

2 Answers2

0

you have to set a connection first(mysql_connect("loclahost","root","","db_name)) in the mysql_query you need 2 parameters 1-connection and 2-query. the error means function cant find any row.

m.moghadam
  • 82
  • 8
0

your query must be like this:

$login_query = "SELECT * from admin_login where user_name='$user_name' AND user_password='$user_pass' ";
Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164