This is the error I get, everytime "mysql_num_rows()" gets called this error comes up. Go to http://shanefaulkner.com and try and log in with anything
Here is my files codeCode:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/shauder/public_html/login.php on line 30
This is the files that connects to the DBCode:<?php include 'inc/php/dbconfig.php'; include 'inc/php/functions.php'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <head> <title>Shane Faulkner | Login</title> <link rel="stylesheet" type="text/css" href="inc/styles/common.css" /> </head> <body> <?php // when the user hits the submit button... if ($_POST['submit']) { // get the variables from the form and protect them $username = protect($_POST['username']); $password = protect($_POST['password']); if (!$username || !$password) { echo 'please enter a username or a password!'; } else { // if they do have both a username and password then // we want to select all usernames from the database that match that username $res = mysql_query("SELECT * FROM 'users' WHERE 'username' = '".$username."'"); $num = mysql_num_rows($res); // now we need to see if there is a match if ($num == 0) { // on fail display error echo 'the username, '.$username.', does not exist in our system!'; } else { $res = mysql_query("SELECT username FROM 'users' WHERE 'username' = '".$username."' AND 'password' = '".$password."'"); // we want to continue a their credentials if they passes $num = mysql_num_rows($res) or die("Error: ". mysql_error(). " with query ". $query); if ($num == 0) { // on fail display error echo 'the password you gave us does not match the username!'; } else { $row = mysql_fetch_assoc($req); if ($row['active'] != 1) { // on fail display error echo 'you still need to activate your account before you can log in!'; } else { // if it is active then log them in $_SESSION['uid'] = $row['id']; echo 'you have been logged in!'; echo 'please wait while we redirect you!'; // update them so they display as online mysql_query("UPDATE 'users' SET 'online' = '".$time."' WHERE 'id' = '".$_SESSION['uid']."'"); // redirect header('location: index.php'); } } } } } ?> <form action="login.php" method="post"> <div id="login"> <p> <label>username: </label> <input name="username" type="text" /> </p> <p> <label>password: </label> <input name="password" type="password" /> </p> <p> <label>remember me: </label> </p> <span><input name="submit" value="login" type="submit"></span> <span><a href="register.php">register</a> | <a href="forgot.php">lost password</a></span> </div> </form> </body> </html>
Any help would be greatly appreciated! I started playing around with it, and I am really knew to PHP so it may be even more messed up then it started lol =/Code:<?php // start a session to see if a user is logged in session_start(); // define database variables $myqhost = 'localhost'; $myqname = '******'; $myquser = '************'; $myqpass = '*************'; $con = mysql_connect($myqhost, $myquser, $myqpass); $db = mysql_select_db($myqname, $con); if (!con) { echo '<p>MySQL connection is <b>bad</b></p>'; } else { echo '<p>MySQL connection is <b>good</b></p>'; } ?>









Bookmarks