This is the file db_connect.php to be included in a file that needs a connection to the database.
<?php // set the database access info as constants DEFINE ('DB_HOST', "localhost"); DEFINE ('DB_USER', "username"); DEFINE ('DB_PASSWORD', "password"); DEFINE ('DB_NAME', "databasename"); DEFINE ('TABLE_NAME', "users"); //Opening the connection to the database server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!link) { die('Not connected : ' . mysql_error()); } // select a database $db_selected = mysql_select_db(DB_NAME, $link); if (!$db_selected) { die ('Can\'t use the database : ' . mysql_error()); } ?> |