Jump to content

HELP!! Errors in login code


louisstephens

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/145839-help-errors-in-login-code/
Share on other sites

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"));

 

 

 

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 );
  }
}
?>

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());

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

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.

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.