Jump to content

php/mysql help


darkside92

Recommended Posts

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";
	}
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...