louisstephens Posted February 19, 2009 Share Posted February 19, 2009 Well, I was following a tutorial on how to use dreamweaver to set up the login page. I followed it exactly. However, I get Warning: mysql_select_db(): supplied resource is not a valid MySQL-Link resource in /home/content/w/o/c/wocoadmin/html/taggr/users/login.php on line 56 when I try to use the page (login).. mysql_select_db($database_users, $users); $LoginRS__query=sprintf("SELECT `user`, password FROM users WHERE `user`=%s AND password=%s", GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text")); Any help would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/ Share on other sites More sharing options...
blueman378 Posted February 19, 2009 Share Posted February 19, 2009 hi mate, try adding or die(mysql_error()); after your querys so basically mysql_select_db($database_users, $users) or die(mysql_error()); $LoginRS__query=sprintf("SELECT `user`, password FROM users WHERE `user`=%s AND password=%s", GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text")); Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-765703 Share on other sites More sharing options...
louisstephens Posted February 19, 2009 Author Share Posted February 19, 2009 Thanks, unfortunately I am still recieving the same errors. (line 56 thru 61) mysql_select_db($database_users, $users); $query_users = "SELECT * FROM users"; $users = mysql_query($query_users, $users) or die(mysql_error()); $row_users = mysql_fetch_assoc($users); $totalRows_users = mysql_num_rows($users); ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['user'])) { $loginUsername=$_POST['user']; $password=$_POST['password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "congrats.php"; $MM_redirectLoginFailed = "login.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_users, $users) or die(mysql_error()); $LoginRS__query=sprintf("SELECT `user`, password FROM users WHERE `user`=%s AND password=%s", GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $users) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-765713 Share on other sites More sharing options...
blueman378 Posted February 19, 2009 Share Posted February 19, 2009 try this mysql_select_db($database_users, $users) or die(mysql_error()); $query_users = "SELECT * FROM users"; $users = mysql_query($query_users, $users) or die(mysql_error()); $row_users = mysql_fetch_assoc($users); $totalRows_users = mysql_num_rows($users) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-765883 Share on other sites More sharing options...
haku Posted February 19, 2009 Share Posted February 19, 2009 You haven't properly connected with the database. Go back to your initial database connection code, and re-check that the host, username and password are all set correctly. Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-765911 Share on other sites More sharing options...
louisstephens Posted February 22, 2009 Author Share Posted February 22, 2009 Thanks for the last bit of help.. That issue is now resolved. However, I am not getting a message saying "Unknown column 'test' in 'where clause'".. (test was my login user name and password stored in the database). I am sorry for all the trouble, I am still trying to learn php Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-768190 Share on other sites More sharing options...
blueman378 Posted February 22, 2009 Share Posted February 22, 2009 this doesnt make sense. I am not getting a message saying "Unknown column 'test' in 'where clause'" did oyu mean i am now? Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-768197 Share on other sites More sharing options...
louisstephens Posted February 22, 2009 Author Share Posted February 22, 2009 Ah, yes.. That is what I meant. I am now getting that error Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-768498 Share on other sites More sharing options...
blueman378 Posted February 22, 2009 Share Posted February 22, 2009 and so what does the error say: unknown column test. ah so that means that there is no column called test in the table you have connected to. remember that column names are CaSe SeNsItIvE Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-768682 Share on other sites More sharing options...
louisstephens Posted February 22, 2009 Author Share Posted February 22, 2009 Yeah, The login information stored under the column "user" was test (username) and test (password). When I enter user for the user name and test for the password it logged in. lol.. I just want it to select the username for it under the column user. Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-768779 Share on other sites More sharing options...
haku Posted February 23, 2009 Share Posted February 23, 2009 Echo the sql query, and look for the error. It will say something like: WHERE test= You don't have a column named 'test' in your sql table, which is why you are getting the error. Also, this is a separate topic, so you should really start a new thread for it. Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-768854 Share on other sites More sharing options...
louisstephens Posted February 23, 2009 Author Share Posted February 23, 2009 Ah. I am sorry. Wont let it happen again. Its just frustrating.. Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-768886 Share on other sites More sharing options...
haku Posted February 23, 2009 Share Posted February 23, 2009 No worries - the suggestion is more for you than me. If you start a new thread, more people are likely to look at it. People seem to often ignore threads that already have a number of posts in them, so when a new topic is brought up in a thread, it often gets skipped. Quote Link to comment https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/#findComment-768899 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.