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
    Regular Coder
    Join Date
    Feb 2003
    Location
    East Side/West Side
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts

    No Database Selected

    PHP Code:
    $link mysql_connect("$config['db_host']","$config['db_user']","$config['db_pass']");
    mysql_select_db("$config['db_name']"); 
    That's the part of my code in an include file that's included in all of my game's files. Yet I get an error saying "No Database Selected" in the login and register files (which are the only files as of yet that use the database). Can anyone help me?

  • #2
    New Coder
    Join Date
    Aug 2002
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: No Database Selected

    Have you tried:

    PHP Code:
    $link mysql_connect("$config['db_host']","$config['db_user']","$config['db_pass']");
    mysql_select_db("$config['db_name']",$link); 

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,058
    Thanks
    10
    Thanked 96 Times in 94 Posts
    if you turn up error reporting levels ...

    PHP Code:
    <?
    error_reporting
    (E_ALL);
    ?>
    you will see errors like
    Notice: Undefined index: 'db_pass' in h:\phpdev\www\test.php on line 5

    as the literal index 'db_pass' quotes and all ... does not exist.

    so removing those double quotes will help !

    PHP Code:
    <?
    mysql_connect
    ($config['db_host'],$config['db_user'],$config['db_pass'])or die("".__LINE__.mysql_error());
    ?>
    note you can also use braces ... "{$config['var']}" ... but there is no point here in doing so.
    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)

  • #4
    Regular Coder
    Join Date
    Feb 2003
    Location
    East Side/West Side
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks that helped :-)


  •  

    Posting Permissions

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