View Full Version : PHP and mysql question

09-02-2006, 05:17 PM
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.

$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.

09-02-2006, 05:25 PM
Is your hostname really "localhost"?

09-02-2006, 06:20 PM
yes it is localhost. The script connects fine to the sql server but not the database

09-02-2006, 07:42 PM
add a call to mysql_error() to your die(), see if that gives anything useful.

Lee Stevens
09-03-2006, 12:55 AM
its normaly: 'yourusername'_'database_name'

So it'll be for me "stevelee_test"

09-03-2006, 01:56 AM
eh? normally?

Lee Stevens
09-03-2006, 10:07 AM
Ok is allways, exept on your local machine.... (