justinh Posted December 12, 2008 Share Posted December 12, 2008 My login form is processed using processlogin.php you can see what goes wrong here: www.wmptest.com/stbs/index.html Error is: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /homepages/29/d119570661/htdocs/wmptest.com/stbs/processlogin.php on line 82 <?php session_start(); include("connect.php"); $username = stripslashes($_POST['username']); $password = stripslashes($_POST['password']); if (!$username || !$password){ ?> <html> <head> <title> South Texas Business Systems - UploadManager </title> <link rel="stylesheet" type="text/css" href="style.css"> <script type="text/javascript"> function showPopup(url) { newwindow=window.open(url,'name','height=190,width=520,top=320,left=100,resizable,scrollable'); if (window.focus) {newwindow.focus()} } </script> </head> <body> <div id="container"> <img src="uploadmanager.jpg"></img><img src="uploadmanager2.jpg"></img><div id="content"> <form method="POST" action="processlogin.php"> <fieldset> <font color="red"><small>Must provide a username and password</small><Br></font> <legend> Login<a href='help.html' onClick='showPopup(this.href);return(false);'>[?]</a> </legend> <label for="username">User Name:</label><input type="text" name="username"> <label for="password">Password:</label><input type="password" name="password"> <input type="submit" class="submitbutton" value="Login"><br><div id="copyright">Copyright 2008-2009© 2008-2009, All rights reserved. This program is protected by local and international copyright laws as described in the license agreement.</div> </fieldset> </form> </div> </div> </body> </html> <? }else{ $finduser = mysql_query("SELECT * FROM tbl_users WHERE username = $username AND password = $password"); if(!finduser){ ?> <html> <head> <title> South Texas Business Systems - UploadManager </title> <link rel="stylesheet" type="text/css" href="style.css"> <script type="text/javascript"> function showPopup(url) { newwindow=window.open(url,'name','height=190,width=520,top=320,left=100,resizable,scrollable'); if (window.focus) {newwindow.focus()} } </script> </head> <body> <div id="container"> <img src="uploadmanager.jpg"></img><img src="uploadmanager2.jpg"></img><div id="content"> <form method="POST" action="processlogin.php"> <fieldset> <font color="red"><small>User name or passsword is incorrect.</small><Br></font> <legend> Login<a href='help.html' onClick='showPopup(this.href);return(false);'>[?]</a> </legend> <label for="username">User Name:</label><input type="text" name="username"> <label for="password">Password:</label><input type="password" name="password"> <input type="submit" class="submitbutton" value="Login"><br><div id="copyright">Copyright 2008-2009© 2008-2009, All rights reserved. This program is protected by local and international copyright laws as described in the license agreement.</div> </fieldset> </form> </div> </div> </body> </html> <? }else{ while($getuserinfo = mysql_fetch_array($finduser)){ $username = $getuserinfo['username']; $rank = $getuserinfo['siterank']; $firstname = $getuserinfo['firstname']; } $_SESSION['loggedin'] = 1; $_SESSION['siterank'] = $rank; $_SESSION['firstname'] = $firstname; ?> <html> <head> <title> South Texas Business Systems - UploadManager</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="container"><img src="uploadmanager.jpg"></img><img src="uploadmanager2.jpg"></img><div id="content2"> <br><br><br><b>Log in successful!</b> <br><img src="ajax-loader.gif" class="loading"></img>Now redirecting you to your account...<meta http-equiv="Refresh" content="5; url=about:blank"> </div> </div> </body> </html> <? } } ?> Link to comment https://forums.phpfreaks.com/topic/136746-mysql-error/ Share on other sites More sharing options...
Flames Posted December 12, 2008 Share Posted December 12, 2008 change $finduser = mysql_query("SELECT * FROM tbl_users WHERE username = $username AND password = $password"); to $finduser = mysql_query("SELECT * FROM tbl_users WHERE username = '$username' AND password = '$password'") or die("Error:".mysql_error()." No:".mysql_errno()); Link to comment https://forums.phpfreaks.com/topic/136746-mysql-error/#findComment-714175 Share on other sites More sharing options...
justinh Posted December 12, 2008 Author Share Posted December 12, 2008 thanks, this gets rid of the error.. but no matter what username and pass you put in, it goes to the login successful. updated version uploaded if you need to see. www.wmptest.com/stbs/index.html Link to comment https://forums.phpfreaks.com/topic/136746-mysql-error/#findComment-714182 Share on other sites More sharing options...
Flames Posted December 12, 2008 Share Posted December 12, 2008 look up mysql_num_rows() and also wrong forum Link to comment https://forums.phpfreaks.com/topic/136746-mysql-error/#findComment-714188 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.