Skip navigation links

MySQL Forums :: PHP :: Unknown MySQL server host 'DB_SERVER' (11004)


Advanced Search

Unknown MySQL server host 'DB_SERVER' (11004)
Posted by: Rosalie Stratford ()
Date: June 10, 2009 07:18AM

I'm currently doing a php oop tutorial, with xamp installed and apache configured for virtual hosts.

I have a config.php page with the constants defined: DB_SERVER(set to 'localhost'), DB_USER, DB_PASS and DB_NAME, all set with username, pswd and db name accordingly.

My database.php page require_once the above and begins as follow:

class MySQLDatabase {

Private $connection;

function __construct() {
$this->open_connection();
}

public function open_connection() {
$this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS);
if (!$this->connection) {
die("Database connection failed: " . mysql_error());
} else {
$db_select = mysql_select_db(DB_NAME, $this->connection);
if (!$db_select) {
die("Database selection failed: " . mysql_error());
}
}
}

The public function open_connection(), 2nd line beginning:$this->connection shows as a mysql_connection() error - Unknown MySQL server host "DB_SERVER"(11004).

Forgive my ignorance as I'm learning. Can anyone advise me please?

Many thanks.

Options: ReplyQuote


Subject Written By Posted
Unknown MySQL server host 'DB_SERVER' (11004) Rosalie Stratford 06/10/2009 07:18AM
Re: Unknown MySQL server host 'DB_SERVER' (11004) Rick James 06/11/2009 08:39PM
Re: Unknown MySQL server host 'DB_SERVER' (11004) Rosalie Stratford 06/12/2009 02:10AM
Re: Unknown MySQL server host 'DB_SERVER' (11004) Rick James 06/12/2009 09:05AM
Re: Unknown MySQL server host 'DB_SERVER' (11004) Rosalie Stratford 06/12/2009 11:42AM
Re: Unknown MySQL server host 'DB_SERVER' (11004) Anna Gherib 08/07/2009 09:27AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.