Bopo Posted March 20, 2009 Share Posted March 20, 2009 Hi Well this is probably one of those silly errors that sometimes you just can't see, I have tried troubleshooting but I still can't find the problem, I get: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result So therefore I used to the following code, however I always get the 'Missing ;' error, which is weird if(!$result){die(mysql_error();} Anyway, here's my code: <form id="form1" name="form1" method="post" action="login.php"> <p> <label>Username: <input type="text" name="username" id="Username" /> </label> </p> <p> <label>Password: <input type="text" name="password" id="Password" /> </label> </p> <p> </p> <p> <label> <input type="submit" name="submit" id="Login" value="Login" /> </label> </p> </form> <?php if(isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; include("../createadmin/adminconnect.php"); $sql = "SELECT username, password FROM adminlogin WHERE username = '$username' AND password '$password'"; $result = mysql_query($sql, $connection); echo "$sql"; if(mysql_num_rows($result)) { $_SESSION['loggedin'] = 1; header('Location: http://www.website.com/admin/admin.php'); exit();} else { header('Location: http://www.website.com/login.php?error1'); exit();} // if(!$result){die(mysql_error();} } ?> Quote Link to comment https://forums.phpfreaks.com/topic/150375-solved-mysql_num_rows-error/ Share on other sites More sharing options...
Yesideez Posted March 20, 2009 Share Posted March 20, 2009 There's no equals sign in your query for the password check. Quote Link to comment https://forums.phpfreaks.com/topic/150375-solved-mysql_num_rows-error/#findComment-789705 Share on other sites More sharing options...
Maq Posted March 20, 2009 Share Posted March 20, 2009 $sql = "SELECT username, password FROM adminlogin WHERE username = '$username' AND password = '$password'"; EDIT: What Yesideez said Quote Link to comment https://forums.phpfreaks.com/topic/150375-solved-mysql_num_rows-error/#findComment-789706 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.