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">

<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" />
<div id="wrapper">

  <p><!-- end #header --></p>
  <div id="header" class="container">
    <div id="logo">
      <h1><a href="#">Yakity Yak</a></h1>
    <div id="menu">
        <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>
      <p> <center><img src="sd.jpg" width="999" height="300"  alt=""/></center>  </p>
  <div id="page">
    <div class="post">
      <h2 class="title"><a href="#">Welcome Admin</a></h2>
<form action="" method="post">


<div class="entry">
<h2>Admin Log In</h2>
<!--Introduction Paragraph-->
    <form action="adminlogin.php" method="POST">
    <table border="0.1">
<td><label for="email">Email Address:</label></td>
<td><input type="text" id="email" name="email"/> <br/> </td>
<td> <label for="password">Password:</label> </td>
<td> <input type="password" id="password:" name="password"/> <br/> </tr>
  <input type="submit" value="Log In" name="LogIn" />

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

<!--PHP Coding Begins here-->
//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");
       } else {
        echo 'Sorry you do not have access to this part of the site. Please use the general "Log In" under the "Home" Tab.';


Edited by dean.ong.14

3 Years
Discussion Span
Last Post by diafol

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.


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');

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.