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
https://forums.phpfreaks.com/topic/71237-user-authentication/
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
https://forums.phpfreaks.com/topic/71237-user-authentication/#findComment-358348
Share on other sites

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.