0
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in F:\xampp\htdocs\s.php on line 95
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR...l1-strict.dtd">
<!--


-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Yakity Yak</title>
<link href='http://fonts.googlea...=Oswald:400,300' rel='stylesheet' type='text/css'>
<link href='http://fonts.googlea...css?family=Abel|Satisfy' rel='stylesheet' type='text/css'>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">

  <p><!-- end #header --></p>
  <div id="header" class="container">
    <div id="logo">
      <h1><a href="#">Yakity Yak</a></h1>
    </div>
    <div id="menu">
      <ul>
        <li class="current_page_item"><a href="homepage.php">Homepage</a></li>
        <li><a href="trip.php">Destinations</a></li>
        <li><a href="contact.php">contact </a></li>
        <li><a href="registration.php">Login</a></li>
        <li><a href="adminlogin.php">Leader</a></li>
        <li></li>
        <li></li>
      </ul>
    </div>
  </div>
  <blockquote>
    <blockquote>
      <p> <center><img src="sd.jpg" width="999" height="300"  alt=""/></center>  </p>
    </blockquote>
  </blockquote>
  <div id="page">
    <div class="post">
      <h2 class="title"><a href="#">Welcome Admin</a></h2>
<form action="" method="post">

</form>
</body>
</html>

<div class="entry">
<h2>Admin Log In</h2>
<!--Introduction Paragraph-->
<p>
    <form action="adminlogin.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" />

 <br><a href="trip2.php">Trip</a></br>
  </form> 
</div>
    </div>
  </div>


<!--PHP Coding Begins here-->
<?php
//defining Varables
$host = "localhost";
$user = "root";
$pass = "";
$db = "admin";
$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: trip2.php");
        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();
    }
}
mysql_close($con);
?>

</body>
</html>

Edited by dean.ong.14

2
Contributors
3
Replies
12
Views
3 Years
Discussion Span
Last Post by diafol
0

If I had a penny for every time this question has been asked...

"Warning: mysql_num_rows() expects parameter 1 to be resource, boolean give..."

It means your query failed so it returned false. You can't run a num_row check on a boolean value.

or die(mysql_error());

Add the above to the end of your query on line 93.

0

still the same problem

$email = $_POST['email'];
    $password = $_POST['password'];
    $sql = "SELECT * FROM users WHERE email = '".$email."' AND password = '".$password."' LIMIT 1 " or die(mysql_error());
    $res = mysql_query ($sql);
    if ((mysql_num_rows($res) == 1) and ($email == $admin)) {
        header ('Location: admin2.php');
        exit();
0

From the solved, I assume you then realised the 'or die' should have gone on the line below (with line 4 above)

Edited by diafol

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.