Jump to content

User Authentication


jimm99

Recommended Posts

:)

Hi all

Please help me.

I am getting these two error messages.They are:

 

Warning: mysqli::mysqli() [function.mysqli-mysqli]: (28000/1045): Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xxxxx\www\abc\xx\Database.class on line 16

 

Warning: mysqli::query() [function.mysqli-query]: Couldn't fetch mysqli in C:\xxxxx\www\abc\xx\Database.class on line 32

Database is not available. Try again later

 

Here is the code :-

<?php

require_once("PasswordPrompter.class");              #@@a10
require_once("Database.class");
require_once("Account.class");
require_once("WebPage.class");

//Testing whether the user has been prompted for a user name
if(!isset($_SERVER['PHP_AUTH_USER']))                #@@a16
{
    try
    {
       $prompter = new PasswordPrompter("secret section");
       $prompter->displayPrompt();
    }
    catch(Exception $e)
    {
       echo $e->getMessage();
       exit();
    }
}

// Testing the user name and password entered by the user
else                                                 #@@a31
{
    try                                               #@@a33
    {
       $db = new Database("Vars.inc");                #@@a35
       $db->useDatabase("UserAccount");               #@@a36
    }
    catch(Exception $e)
    {
       echo $e->getMessage();
       exit();
    }                                                 #@@a42
    try                                               #@@a43
    {
       $acct = new 
          Account($db->getConnection(),"Valid_User"); #@@a46
       if(!$acct->selectAccount($_SERVER['PHP_AUTH_USER']))
       {
          $mess = $acct->getMessage();
          echo $mess."<br>";
          exit();
       }                                              #@@a52
       if(!$acct->comparePassword($_SERVER['PHP_AUTH_PW']) )
       {
          $mess = $acct->getMessage();
          echo $mess."<br>";
          exit();
       }                                              #@@a58
    }
    catch(Exception $e)
    {
       echo $e->getMessage();
       exit();
    }
  }                                                   #@@a65
  $data['user_name'] = $_SERVER['PHP_AUTH_USER'];     #@@a66
  try                                                 #@@a67
  {
    $welcome_page = new WebPage("Welcome.inc",$data); #@@a69
    $welcome_page->displayPage();                     #@@a70
  }
  catch(Exception $e)
  {
    echo $e->getMessage();
    exit();
  }
?>

 

And,when I run this program,I get a login box asking for user name & password.When I supply the user name & password I get the above mentioned error messages !

I have already created a password list file,& created a "useraccount" database with a user & password.

Then why i am getting this error?

I should be getting a welcome page which I am not getting.

 

And my database.class file has this code in line 16 :-

 

if(!$this->cxn = new mysqli($host,$user,$passwd))

 

And,line 32 has this :-

if(!$result = $this->cxn->query("SHOW DATABASES"))

 

With Regards

Thanks in advance

Link to comment
Share on other sites

Warning: mysqli::mysqli() [function.mysqli-mysqli]: (28000/1045): Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xxxxx\www\abc\xx\Database.class on line 16

This line looks like it's indicating it doesn't recognise the username. Have you got a mysql server running and set up a user, password, some privileges and a database. If not then this is why your getting the error.

 

I'm not sure of the classes that your using, but you'd be better off testing with something simple, such as:

$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
    or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');

As taken from the manual: http://uk3.php.net/manual/en/ref.mysql.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.