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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post

    PHP and mysql question

    I am new to PHP and MYSQL and am trying to learn it. I am trying to run a simple script but it keeps telling me that the database does not exist.

    PHP Code:
    <?php
    $dbuser
    ="---------";
    $dbpass="---------";
    $dbname="jacobb-1"//the name of the database
    $chandle mysql_connect("localhost"$dbuser$dbpass)
    or die(
    "Connection Failure to Database");
    mysql_select_db($dbname$chandle) or die ($dbname " Database not found. ");

    ?>
    Iit keeps telling me that the database is not found. it connects allright but then gives the error that the databsae is not found. Can someone tell me why? I have made sure that the DB name is correct. I'm at a loss here.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Is your hostname really "localhost"?

  • #3
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post

    yes

    yes it is localhost. The script connects fine to the sql server but not the database

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    add a call to mysql_error() to your die(), see if that gives anything useful.

  • #5
    Regular Coder
    Join Date
    Aug 2006
    Location
    UK, London, Dartford
    Posts
    221
    Thanks
    3
    Thanked 14 Times in 14 Posts
    its normaly: 'yourusername'_'database_name'

    So it'll be for me "stevelee_test"

  • #6
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    eh? normally?

  • #7
    Regular Coder
    Join Date
    Aug 2006
    Location
    UK, London, Dartford
    Posts
    221
    Thanks
    3
    Thanked 14 Times in 14 Posts
    Ok is allways, exept on your local machine.... (127.0.0.1)


  •  

    Posting Permissions

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