Database not available

Discussion in 'PHP' started by 11ul, Sep 30, 2007.

  1. #1
    Please help me.
    I get 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();
      }
    ?>
    
    
    PHP:
     
    11ul, Sep 30, 2007 IP
  2. 11ul

    11ul Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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"))
    Hello...anybody there?
     
    11ul, Sep 30, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    The error is telling you that the MySQLi username or password is incorrect.

    Note that this username and password has nothing to do with the prompt window that appears.

    Ask your host if you're unsure about it.
     
    nico_swd, Sep 30, 2007 IP
  4. 11ul

    11ul Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello,

    Can you please guide me as to how to rectify the error?Where can I find the user name & password for mysqli & how to change it?
    Host means?I am using my own wamp server
    Please Help...

    With Regards
    Thanks
     
    11ul, Sep 30, 2007 IP
  5. 11ul

    11ul Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hello anyone there?:rolleyes:
    Please help
     
    11ul, Sep 30, 2007 IP