View Full Version : Problem using Dreamweaver to connect to MySQL database

Feb 21, 2006, 04:01 PM
I'm completely new to web database programming and I'm trying to do the equivalent of a 'hello world' application - i.e. all I want to do is create a page that will magically pull some data from a database (proof of concept if you like).

So I've got Dreamweaver, I've got MySQL setup and I've created a database and a few tables and put a bit of data into them.

When I try to create a connection one of two things happens...

If I specify a valid username/password combination I get error 1045 Access Denied for user....

Or, If I just specify any old username and no password I get two databases (not mine) 'information_schema' and 'test' which I can happily query.

But i want to query my database.....

Feb 21, 2006, 04:05 PM
Where have you set up the new MySQL database? Have you specified your php script to use that server?

I may also help if you post the code from the php file (use the php tags)... ;)

Edit: In particular the database info, like this:


$link = mysql_connect($DB_Host, $DB_User, $DB_Pass);
and the queries
$query = "SELECT whatever FROM table WHERE something matches";
$result = mysql_db_query($DB_Name, $query, $link);

Feb 22, 2006, 04:57 AM
just another way with different type of error checking. The php script will die if doesn't connect the db.

//connect to the database server

define('DB_USER', 'user name');
define('DB_PASSWORD', 'password here');
define('DB_HOST','localhost or addy');
define('DB_NAME', 'db name');

//@ turns off messages
$dbc = @mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);

if(!$dbc) {
die( '<p>Unable to connect to the ' .
'database server at this time. </p>' );


if(! @mysql_select_db(DB_NAME) ) {
die( '<p>Unable to locate the DB_NAME ' .
'database at this time.</p>' );