dean012 Posted December 1, 2013 Share Posted December 1, 2013 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in F:\xampp\htdocs\s.php on line 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> Quote Link to comment Share on other sites More sharing options...
aysiu Posted December 1, 2013 Share Posted December 1, 2013 (edited) 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 December 1, 2013 by aysiu Quote Link to comment Share on other sites More sharing options...
dean012 Posted December 1, 2013 Author Share Posted December 1, 2013 i dont get the hash thing Quote Link to comment Share on other sites More sharing options...
aysiu Posted December 1, 2013 Share Posted December 1, 2013 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. Quote Link to comment Share on other sites More sharing options...
dean012 Posted December 1, 2013 Author Share Posted December 1, 2013 can you edit the code? Quote Link to comment Share on other sites More sharing options...
Barand Posted December 1, 2013 Share Posted December 1, 2013 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() ); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.