Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Problem with my login screen

New Here ,
Sep 18, 2009 Sep 18, 2009

Copy link to clipboard

Copied

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).

TOPICS
Server side applications

Views

2.2K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 19, 2009 Sep 19, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2009 Sep 19, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 19, 2009 Sep 19, 2009

Copy link to clipboard

Copied

Dreamweaver automatically adds the code to make the connection, when you select the relevant connection in the server behavior dialog box. The first line of code in your page should look something like this:

<?php require_once('../../Connections/connAdmin.php'); ?>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2009 Sep 19, 2009

Copy link to clipboard

Copied

I must have done something out of sequence when I first posted this problem.  When I looked at the code now  the first lin of code is, in fact:

<?php require_once('Connections/LogIn.php'); ?>

Then came the rest as shown in my original post, however I still get the same errors.  I tried looking at all the generated code to see if I could identify a problem, but It's all pretty much still over my head, and since it's genereated, I figured I shouldn't mess with it.

Any ideas?  Here's a re-post of the php code, in case it's changed since my original post.

<?php require_once('Connections/LogIn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;   
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
 
  return $theValue;
}
?>
<?php

I just looked back at my original post, and either I missed some when I copied/pasted it or in my floundering around afterward, I managed to get more generated.  I'm snowed.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 19, 2009 Sep 19, 2009

Copy link to clipboard

Copied

Is MySQL running?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 20, 2009 Sep 20, 2009

Copy link to clipboard

Copied

Is MySQL running?

Yup! I opened my XAMPP Control Panel, and all the services indicate that thay're running (i.e. Apache, MySQL, FileZilla & Mercury).

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 23, 2009 Sep 23, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 24, 2009 Sep 24, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2009 Sep 24, 2009

Copy link to clipboard

Copied

Hi David,

Thanks for the response. I did exactly as you instructed, and when I pressed the "Test" button, a pop-up appeared which read, "Connection was made successfully". However, when I then executed the form, the same fatal errors occurred. This is really creepy.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 24, 2009 Sep 24, 2009

Copy link to clipboard

Copied

Have you tried starting with a blank page and building it all again from scratch?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2009 Sep 24, 2009

Copy link to clipboard

Copied

I had hoped it wouldn't come to that, because that will set me back in my schedule, but I guess that's the only thing left to do.  I only hope that this time I do things in the right sequence.  I don't even remember where on the Adobe site I found the instructions.  Could you steer me to that please?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 25, 2009 Sep 25, 2009

Copy link to clipboard

Copied

http://help.adobe.com/en_US/Dreamweaver/10.0_Using/WScbb6b82af5544594822510a94ae8d65-78d3a.html

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 25, 2009 Sep 25, 2009

Copy link to clipboard

Copied

LATEST

Got 'er Dunn!  Thankfully I didn't have to go completely back to a blank form; I was able to remove the behavior, delete the PHP script then redo the behavior etc.  I followed your link and followed the sequence exactly and, "Voila!", it works.  Thank you so much for the suggestion and the link.  They did the trick.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines