Problem using Dreamweaver to connect to MySQL database

Discussion in 'Web Design and Development' started by jh100000, Feb 21, 2006.

  1. macrumors newbie

    Feb 11, 2005
    London, UK
    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.....
  2. Moderator emeritus


    Mar 10, 2004
    Bergen, Norway
    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);
  3. macrumors 68030


    Nov 7, 2003
    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);
    $dbc) {
    '<p>Unable to connect to the ' .
    'database server at this time. </p>' );


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


Share This Page