Skip to main content
Known Participant
September 18, 2009
Question

Problem with my login screen

  • September 18, 2009
  • 1 reply
  • 2232 views

I created a mysql database, a connection in Dreamweaver, and a login page using the tutorials here on the Adobe site.  I thought I had followed everything according to the tutorials, using the "server behaviors" as instructed, but when I try to execute it, I get the following error:

Warning: mysql_select_db() expects parameter 2 to be resource, null given in C:\xampp\htdocs\IOD\loginToIOD.php on line 52

Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\htdocs\IOD\loginToIOD.php on line 57

Here's the code in that area of the page:

<?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['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "WOTCPg1.php";
  $MM_redirectLoginFailed = "loginerror.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_LogIn, $LogIn);
 
  $LoginRS__query=sprintf("SELECT UserID, Password FROM authentication WHERE UserID=%s AND Password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  
  $LoginRS = mysql_query($LoginRS__query, $LogIn) 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 );
  }
}
?>

The mysql database is named "InfoOnDemand".  It currently contains only 1 table, named "Authenticate", with just one record.  The table fields are:

UserID CHAR 30; Password CHAR 20; CustID CHAR 20 and Status CHAR 10 Default value "in" (that should be "out", but I haven't changed it yet).

This topic has been closed for replies.

1 reply

David_Powers
Inspiring
September 19, 2009

The second parameter passed to both mysql_select_db() and mysql_query() is a reference to the database connection. Judging from the error messages and the code you have posted here, you don't have a MySQL connection defined on that page.

Known Participant
September 19, 2009

I guess I'm a little confused then.  As instructed by the tutorial, I created the database connection using the "Database" panel, and I can view the authentication table's data from there.  Am I supposed to also make that connection on each page that addresse the table?  If so, I don't know how, as I didn't see anything to that effect in the tutorial.  I'm certain that the problem must be in the page, but since its mostly generated code from the "Log In Behaviors" selection, I don't know what to do next.

David_Powers
Inspiring
September 24, 2009

I've checked everything I know to check (which aint much); all the XAMPP services are running (according the the XAMPP Control Console).  I don't yet understand all the generated code, to be able to debug it, but I'm still getting those same fatal errors, as quoted in my previous posts.

Can anyone tell me what I'm doing wrong?  I really need to get this login working.

Should I re-post this problem in a new thread?  Please, someone help me.


creacontech wrote:

Should I re-post this problem in a new thread?

No. Duplicate threads are likely to get deleted.

The problem is that the fatal error message says that the second parameter is not a database resource. The database resource is created by the MySQL connection, which in your case is Connections/Login.php.

What is unusual about your situation is that a fatal error is being displayed, but no error is generated by the MySQL connection. Open the Databases panel, and double-click LogIn to reopen the MySQL Connection dialog box. Click Test to make sure that the connection is being made successfully.