Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2003
    Location
    texas
    Posts
    96
    Thanks
    1
    Thanked 0 Times in 0 Posts

    another PHP error with connection to a database

    Does anyone see anything that is out of the ordernary with my code, I have made sure that the username and password are 100% correct but I keep getting this one error, and it is something that I am not familar with...I will post it at the end of the code, but this is the code, minus the actual password

    <?
    $dbh=mysql_connect ("localhost", "stevenbr", "password") or die ('I cannot connect to the database because: ' . mysql_error());
    $display = mysql_select_db ("nursing_Nursing");

    extract($_GET);
    $query = "select * from $display";

    if(!isset($display))
    {
    $display = "nursing";
    }

    $result = mysql_db_query($dbh, $query) or die ('Sorry we can not use the database: ' . mysql_error());
    ?>
    some html code is here
    <?
    echo $obj[1];
    ?>

    <?
    echo $obj[2];
    ?>
    close of html code
    <?
    mysql_free_result($result);

    mysql_close($db);
    ?>

    the error is
    Sorry we can not use the database: Access denied for user: 'nursing_stevenbr@localhost' to database 'Resource id #2'
    thanks
    bri

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    suspect this will fix ...

    mysql_select_db( 'nursing_Nursing', $dbh) or die ('Can\'t use nursing_Nursing: ' . mysql_error());

    ...if not then you probably have the correct permissions to connect to localhost but not for the nursing_Nursing database , in which case you need to add the user stevenbr to nursing_Nursing
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •