MySQL Forums
Forum List  »  PHP

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)
June 10, 2009 07:18AM


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.