darkside92 Posted November 19, 2009 Share Posted November 19, 2009 i log in to test my login script it gos to run the check_login.php script and i get this error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jaccbpac/public_html/classnest/check_login.php on line 22 Wrong Email Or Password <?php include "db.php"; ?> <?php mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $email=$_POST['email']; $password=$_POST['password']; $email = stripslashes($email); $password = stripslashes($password); $email = mysql_real_escape_string($email); $password = mysql_real_escape_string($password); $sql="SELECT * FROM $tbl_name WHERE email='$email' and password='$password'"; $result = mysql_query($sql); $count = mysql_num_rows($result); if($count == 1){ session_register("email"); session_register("password"); header("location:login_success.php"); } else{ echo "Wrong Email Or Password"; } ?> Quote Link to comment Share on other sites More sharing options...
%_% Posted November 19, 2009 Share Posted November 19, 2009 i log in to test my login script it gos to run the check_login.php script and i get this error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jaccbpac/public_html/classnest/check_login.php on line 22 Wrong Email Or Password <?php include "db.php"; ?> <?php mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $email=$_POST['email']; $password=$_POST['password']; $email = stripslashes($email); $password = stripslashes($password); $email = mysql_real_escape_string($email); $password = mysql_real_escape_string($password); $sql="SELECT * FROM $tbl_name WHERE email='$email' and password='$password'"; $result = mysql_query($sql); $count = mysql_num_rows($result); if($count == 1){ session_register("email"); session_register("password"); header("location:login_success.php"); } else{ echo "Wrong Email Or Password"; } ?> It appears that in your sql query you are missing the variable tbl_name. I would try putting that in an seeing if you still get the same error Quote Link to comment Share on other sites More sharing options...
darkside92 Posted November 20, 2009 Author Share Posted November 20, 2009 i have it in the include Quote Link to comment Share on other sites More sharing options...
Burncycle Posted November 20, 2009 Share Posted November 20, 2009 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/jaccbpac/public_html/classnest/check_login.php on line 22 This error typically occurs when there is an error in the query. What you can do is add the following immediately after you execute the query: if( mysql_errno() > 0 ) { print "'" . $sql . "' - "; print mysql_error(); exit; } If there is a problem, you will then see the actual mysql error and what the actual query you ran was. Quote Link to comment Share on other sites More sharing options...
darkside92 Posted November 20, 2009 Author Share Posted November 20, 2009 it works fine now i dident even touch the script yet must of been my hosting Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.