hello all
this is my first post here but please bear with me
I'm trying to create a login script, and I got a issue
this is the error I get
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/login.php on line 26
this is my code
<?php
ob_start();
$host="localhost";
$username="gwolf2u";
$password="zzz";
$db_name="db";
$tbl_name="members";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['username'];
$pass=$_POST['pass'];
$myusername = stripslashes($myusername);
$pass = stripslashes($pass);
$myusername = mysql_real_escape_string($myusername);
$pass = mysql_real_escape_string($pass);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and serial_no='$pass'";
$count=mysql_num_rows(mysql_query($sql));
if($count==1){
session_register("myusername");
session_register("mykey");
header("location:http://bing.com");
exit;
}
else {
echo $myusername;
echo $pass;
echo $result;
echo $count;
//header("location:http://google.com");
exit;
}
$_SESSION["username"] = $_POST['username'];
ob_end_flush();
?>
now in my db I have a username test and pass test123
when I try to "login", I get my error
what is wrong?
echo $myusername; and echo $pass; are optional I know, but added to test and see if data is passed correct from form to php
any help is highly appreciated