Hi guys.
My last issue was resolved, but now I have an even bigger one.

My login script is meant to scan the database for the username a password entered, and if they match, set a cookie and display a welcome message.

But it doesn't.

<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);

//Connects to database
require("../config.php");

$user = $_POST['user'];
$pass = $_POST['pass'];
$user = strtolower($user);

if (is_dir ('../install'))
{
header('Location: ../install/error.php');
}
else
{

if ($user == "" or $pass == "")
{
header('Location: login.php');
}
else
{

//Requires header
require("includes/header.php");

mysql_select_db($dbname,$connect);
$login_sql = "SELECT user_title, user_password FROM easybb_users WHERE user_title = '".$_POST['user']."' AND user_password = PASSWORD('".$_POST['pass']."')";
$login_res = mysql_query($login_sql,$connect);

//Get number of rows. Should be 1 if a match
if (mysql_num_rows($login_res) == 1)
{

//If a match, get values of username
while($info = mysql_fetch_array($login_res))
{
$user_title = stripslashes($info['user_title']);
}

//Set auth cookie
setcookie("logged", "*E5805F1AE06514B2C19FB2A223F3D0A27DB2F003", time()+86400);

  echo "<div id='starter'>
  <div class='border'>
	<div class='block'>
		<div class='bottom'>
  <h3>Login</h3>
		</div>
		<ol>
You have successfully logged in as '".$_POST['user']."'.
  		</ol>
  		</div>
  	</div>
  </div><br/>";

}
else
{

  echo "<div id='starter'>
  <div class='border'>
	<div class='block'>
		<div class='bottom'>
  <h3>Login</h3>
		</div>
		<ol>
You could not be logged in.
  		</ol>
  		</div>
  	</div>
  </div><br/>";

}

//Requires footer
require("includes/footer.php");

}
}

//Closes connection
mysql_close($connect);

?>

The errors I got:

Warning: mysql_select_db(): 6 is not a valid MySQL-Link resource in C:\apache2triad\htdocs\easybb\login\do_login.php on line 30
Warning: mysql_query(): 6 is not a valid MySQL-Link resource in C:\apache2triad\htdocs\easybb\login\do_login.php on line 32
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\apache2triad\htdocs\easybb\login\do_login.php on line 35
Warning: mysql_close(): 6 is not a valid MySQL-Link resource in C:\apache2triad\htdocs\easybb\login\do_login.php on line 86

Thanks,
- Poomie

    It's apparent that $connect is not a valid MySQL link resource ID. Check your config.php file and make sure that it is assigning the result of mysql_connect() to that variable, and if so then check that you are properly trapping errors if it fails.

      Well my config.php file looks like this (took out some of the connection details for security):

      <?php
      $dbhost = 'localhost';
      $dbuser = 'insanema_easybb';
      $dbpass = '--------';
      $dbname = 'insanema_easybb';
      $forumname = 'EasyBB';
      
      $connect = mysql_connect($dbhost,$dbuser,$dbpass,$dbname);
      if (!$connect)
        {
        die('Could not connect ' . mysql_error());
        }
      ?>

      -Poomie

        I don't see anything wrong in the include file. Is there any possibility that the header.php include file is overwriting the value of $connect? Other than that, before the first line that generates an error you might want to do a var_dump($connect); and see what it says about it.

          Well now I get an error in login.php on line 15; Undefined index.

          Line 15:

          if (!$_COOKIE['logged'] == "*E5805F1AE06514B2C19FB2A223F3D0A27DB2F003")
          • Poomie
            Write a Reply...