+ Reply to Thread
Results 1 to 4 of 4

Thread: mysql_select_db not working with php page

  1. #1
    tmv105 is offline x10Hosting Member tmv105 is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    4

    Unhappy mysql_select_db not working with php page

    I keep getting the error that "No database selected". I have a "Connections" file that contains this:
    Code:
    <?php
    $hostname_diehl = "localhost";
    $database_diehl = "tmv105_*****";
    $username_diehl = "tmv105_*****l";
    $password_diehl = "********";
    $diehl = mysql_connect($hostname_diehl, $username_diehl, $password_diehl) or trigger_error(mysql_error(),E_USER_ERROR); 
    ?>
    ....and then my PHP page using these variables has this code:

    Code:
    mysql_select_db($database_diehl, $diehl);
    And a page that is all but blank with the error "No database selected" appears. I have tried hard coding the database information into the statement and still no luck. Please help!
    Last edited by tmv105; 07-24-2009 at 09:01 AM. Reason: Had my vital information (usernames and passwords) included in my example

  2. #2
    zapzack is offline x10 Elder zapzack is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    606

    Re: mysql_select_db not working with php page

    Did you add the user to the database in cPanel?

  3. #3
    tmv105 is offline x10Hosting Member tmv105 is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    4

    Re: mysql_select_db not working with php page

    Duh! Thanks....it is not clear that after you create the user that they are not actually added to database. My user appeared to be there, but indeed under the username I needed to click the "add" button to administer privileges. Thanks again!

  4. #4
    zapzack is offline x10 Elder zapzack is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    606

    Re: mysql_select_db not working with php page

    No problem.. This happened to me years ago when I started my own website.. Heh
    Last edited by zapzack; 07-24-2009 at 09:55 AM.

+ Reply to Thread

Similar Threads

  1. white php page
    By monsterm in forum Free Hosting
    Replies: 8
    Last Post: 07-11-2009, 02:37 PM
  2. Use PHP to add Content to page through Admin
    By goldy30 in forum Programming Help
    Replies: 1
    Last Post: 11-12-2008, 11:13 PM
  3. Intermediate PHP Not working on Stoli?
    By tondopie in forum Free Hosting
    Replies: 1
    Last Post: 05-07-2008, 06:34 PM
  4. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers