I am getting the following error -
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\wamp\www\...\signin.php on line 7
Call Stack
# Time Memory Function Location
1 0.0281 373480 {main}( ) ..\signin.php:0
2 0.0571 380104 mysql_num_rows ( ) ..\signin.php:7
The code is as follows -
PHP Code:
<?php
extract($_POST);
$cn=mysql_connect('localhost','root','');
mysql_select_db('db1',$cn);
$sql="select user_type from user_dtl where login='$uname' and passwd='$pswd'";
$result=mysql_query($sql,$cn);
$num=mysql_num_rows($result);
if($num>0)
{
$utype=mysql_result($result,0,"user_type");
session_start();
$_SESSION['utype']=$utype;
$_SESSION['uname']=$uname;
if($utype=="A")
{
header('location:admin.php');
}
else if($utype=="G")
{
header('location:home.php');
}
}
else
{
echo "Invalid username/password.<a href='signin.html'>Try again</a>";
}
?>
I have created the database "db1" with a table called 'user_dtl' with the following fields - 'uname','pswd','user_type' .
Are the field names and the names used in the program matching?
If not pls tell me how to rectify the code .
Will be very much thankful.
Bookmarks