Jump to content

Warning: mysql_num_rows():


Gatsu
 Share

Recommended Posts

hi, why do I get this error?Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in E:\xampp\htdocs\t\logincfg.php on line 25Wrong Username or PasswordI use this login script and it works on my other page.

<?phpsession_start();$_SESSION['id']=1;ob_start();$host="localhost"; // Host name$username="******"; // Mysql username$password="******"; // Mysql password$db_name="**********"; // Database name$tbl_name="accounts"; // Table name// Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB");// Define $myusername and $mypassword$myusername=$_POST['id'];$mypassword=$_POST['password'];$sql="SELECT * FROM $tbl_name WHERE login='$myusername' and pass='$mypassword'";$result=mysql_query($sql);// Mysql_num_row is counting table row$count=mysql_num_rows($result);// If result matched $myusername and $mypassword, table row must be 1 rowif($count==1){// Register $myusername, $mypassword and redirect to file "account.php"$_SESSION['id']=$myusername;session_register("id");session_register("password");header("location: account.php");}else {echo "Wrong Username or Password";}ob_end_flush();?>

Line 25 = $count=mysql_num_rows($result);anybody have a solution for this?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...