Jump to content

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in F:\xampp\htdocs\s.php on line 105


Recommended Posts

Warning: mysql_num_rows() expectsarrow-10x10.png parameter 1 to be resource, boolean given in F:\xampp\htdocs\s.php on linearrow-10x10.png 105

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta name = "description" content = "Admin Log In Section"/>
<meta name = "keywords" content = "Admin, Log In, Canoe & Kayak, Hidden Section"/> 
<title> Admin Log In </title>
<link rel = "stylesheet" type = "text/css" href = "Style.css"/>
</head>

<body>
<div id = "wrapper">
<div id = "container">
<div id = "banner">
<h1><center>
 <a href="Index.html"><img src="Images/CanoeAndKayakLogo.png" width="215" height="75" alt="Canoe & Kayak Logo" /></a>
 Wellington Canoe & Kayak - Discover Our World!
 <a href="Index.html"><img src="Images/CanoeAndKayakLogo.png" width="215" height="75" alt="Canoe & Kayak Logo" /><br></a>
 <div id="menu">
<!--Home Drop Down-->
<ul>
<li><a href="Index.html"> Home </a>
<ul>
<li><a href="Sign_Up.html"> Sign Up</a></li> 
<li><a href="Log_In.php"> Log In</a></li> 
<li><a href="Log_Out.php"> Log Out</a></li>
 

</ul><!--closure of inner Ul tag-->
</li><!--Closing the main li tag-->
</ul><!--End of ul tag-->

<!--Trips Drop Down-->
<ul>
<li><a href="Trips.html"> Trips </a>
<ul>
<li><a href="Abel_Tasman.html"> Abel Tasman</a></li> 
<li><a href="Fiordland.html"> Fiordland</a></li> 
<li><a href="Marlborough.html"> Marlborough</a></li>
<li><a href="Nelson_Lakes.html"> Nelson Lakes</a></li>  
<li><a href="Solomons.html"> Solomons</a></li>  
<li><a href="Taupo.html"> Taupo</a></li>
<li><a href="Whanganui.html"> Whanganui</a></li>  

</ul><!--closure of inner Ul tag-->
</li><!--Closing the main li tag-->
</ul><!--End of ul tag-->

<!--others Drop Down-->
<ul>
<li><a href="Others.html"> Others </a>
<ul>
<li><a href="Contact_Us.html"> Contact Us</a></li> 
<li><a href="Photos.html"> Photos</a></li>  

</ul><!--closure of inner Ul tag-->
</li><!--Closing the main li tag-->
</ul><!--End of ul tag-->
</div><!--End of main Menu-->
</center></h1>
</div>
<div id = "left">

</div>
<div id = "right">
<br/>

<!--Contents header-->
<h2>Admin Log In</h2>
<!--Introduction Paragraph-->
<p>
	<form action="Admin_Log_In.php" method="POST">
	<table border="0.1">
<tr>
<td><label for="email">Email Address:</label></td>
<td><input type="text" id="email" name="email"/> <br/> </td>
</tr>
<tr>	
<td> <label for="password">Password:</label> </td>
<td> <input type="password" id="password:" name="password"/> <br/> </tr>
</tr>
</table>
  <input type="submit" value="Log In" name="LogIn" />
  </form> 
  
<!--PHP Coding Begins here-->
<?php
//defining Varables
$host = "localhost";
$user = "root";
$pass = "";
$db = "kayaks_club";
$admin = "wellington@canoeandkayak.co.nz";

mysql_connect ($host, $user, $pass);
mysql_select_db ($db);

//Checking to see if the user has inputed any information
if(isset ($_POST['email'])) {
	$email = $_POST['email'];
	$password = $_POST['password'];
	$sql = "SELECT * FROM users WHERE email = '".$email."' AND password = '".$password."' LIMIT 1 ";
	$res = mysql_query ($sql);
	if ((mysql_num_rows($res) == 1) and ($email == $admin)) {
		header ("Location: Admin_Index.html");
		exit();
	} else {
		echo 'Sorry you do not have access to this part of the site. Please use the general "Log In" under the "Home" Tab.';
		exit();
	}
}

?>
</div>
<div id ="footer">
<a href="Admin_Log_In.php"><br/>The Wellington Canoe & Kayak</a><br/>PO Box 23456<br/>Wellington<br/>Telephone:04 4776911<br/>Email: wellington@canoeandkayak.co.nz<br/>
</div>
</div>
</div>

</body>
</html>

It means this query failed:

$sql = "SELECT * FROM users WHERE email = '".$email."' AND password = '".$password."' LIMIT 1 ";
    $res = mysql_query ($sql);

P.S. The mysql extension is deprecated:

http://www.php.net/manual/en/intro.mysql.php

 

P.P.S. You should hash your passwords:

http://us2.php.net/manual/en/function.password-hash.php

Edited by aysiu

i dont get the hash thing

That's not why you're getting an error. You're getting an error because your query failed.

 

The hash thing is a separate but very real problem. It looks as if you're storing your passwords in plain text instead of hashing them.

This your second post in 24 hours about a failing query. Check your queries for errors using mysql_error() to find out what is wrong.

$sql = "SELECT * FROM users WHERE email = '".$email."' AND password = '".$password."' LIMIT 1 ";
    $res = mysql_query ($sql) or die(mysql_error() );
This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.