Results 1 to 3 of 3

Thread: Can't use db : No database selected

  1. #1

    Default Can't use db : No database selected

    Hi,

    I have a new LAMP install, that seem to work perfectly - individually. Apache, MySQL, PHP and phpMyAdmin

    Trying to connect PHP and MySQL

    Using

    <?
    $username="username";
    $password="password";
    $database="username-databaseName";
    ?>
    and then

    // Opens a connection to a MySQL server
    $connection = mysql_connect ("localhost", $username, $password);
    if (!$connection) {
    die('Not connected : ' . mysql_error());
    }
    when i load the page i get the error

    Can't use db : No database selected
    Please help

  2. #2
    ab@novell.com NNTP User

    Default Re: Can't use db : No database selected

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    A few things.... mysql_connect (in PHP) returns a resource, not a
    boolean, so be careful there. With that said...

    Finish it:

    http://us2.php.net/mysql_select_db

    Good luck.





    d quixote wrote:
    > Hi,
    >
    > I have a new LAMP install, that seem to work perfectly - individually.
    > Apache, MySQL, PHP and phpMyAdmin
    >
    > Trying to connect PHP and MySQL
    >
    > Using
    >
    >> <?
    >> $username="username";
    >> $password="password";
    >> $database="username-databaseName";
    >> ?>

    >
    > and then
    >
    >> // Opens a connection to a MySQL server
    >> $connection = mysql_connect ("localhost", $username, $password);
    >> if (!$connection) {
    >> die('Not connected : ' . mysql_error());
    >> }
    >>

    >
    > when i load the page i get the error
    >
    >> Can't use db : No database selected

    >
    > Please help
    >
    >

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFJjEyh3s42bA80+9kRAn1pAJ4hA9ufnNvNAAnJYFjiwwfGLqP/ewCfQZBR
    /REbbflz1lK1yu+nCtRIbTE=
    =0uf3
    -----END PGP SIGNATURE-----

  3. #3

    Default Re: Can't use db : No database selected

    It worked! Thank you.

Posting Permissions

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