Haing trouble with Login Page

I’m doing some login authentication but for some reason I’m getting an error on my if statement. Here’s the code:

[php]<?php

if (isset($_POST[‘LoginSubmit’])) {

$Username = $_POST['logName'];
$Password = $_POST['logPass'];
$Hashed_Password = sha1($Password);

// 3. Perform database query to check login
$result_set = mysql_query("Select * FROM users WHERE userName = '$Username' AND hashed_password = '$Hashed_Password' LIMIT 1");

if (mysql_num_rows($result_set) == 1) {
	// user authenticated
	header("Location: http://localhost/CAServer/game.php");
} else {
	// username/password combo not correct
	echo "user not found.";
}

}

?>[/php]

the problem is with the line “if (mysql_num_rows($result_set) == 1) {”

I’m getting the error:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\CAserver\index.php on line 37

I’m not sure why I’m getting this error, any help you guys can provide would be great.

that error means the query didn’t work. Check the input variables and the form name spellings for the text fields.

Solved it thank you, I just forgot to include the file setting my database connection.

That would do it, i just figured it was in another part of the script :slight_smile: I marked the topic solved.

Sponsor our Newsletter | Privacy Policy | Terms of Service