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 4 of 4
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "Unable to select requested database."

    i currenty run a game. Well just adding flies now and sorting it out etc..... but when i go to like online.php or anyother flie that the DB runs off.. i get "Unable to select requested database."

    Can anyone tell me that problem?

  • #2
    Regular Coder
    Join Date
    Jun 2005
    Posts
    804
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's not a listed MySQL error message. You need to use mysql_error() and/or mysql_errno() to find out what the server's error message is.

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It actully come's from DB_connect.php:
    PHP Code:
    <?php
    $mysql_server 
    "localhost";
    $mysql_user "disaster";
    $mysql_password "*******";
    $mysql_database "disaster";
     




    $connection mysql_connect("$mysql_server","$mysql_user","$mysql_password") or die ("Unable to connect to MySQL server.");
    $db mysql_select_db("$mysql_database") or die ("Unable to select requested database.");




    ?>

  • #4
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    Yes it does, but those are hand coded error messages. you could just as easily change those messages to "the moon is made out of green cheese" and that would show up. it doesn't tell you what the error is though.

    change your code so it is the following:

    PHP Code:

    $connection 
    mysql_connect("$mysql_server","$mysql_user","$mysql_password"
    or die (
    "Unable to connect to MySQL server.") . mysql_error();
    $db mysql_select_db("$mysql_database"
    or die (
    "Unable to select requested database.") . mysql_error(); 
    you will now get proper error messages from mysql so you can diagnose what the problem is.


  •  

    Posting Permissions

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