Its usual (at the time of writing) storing connection information in constants, in a file called config.php or similar. Due to the sensitive nature of the contents of the files, it is also nice to save this file outside the root of the website.
So, you would in config.php :
<?php define('DBHOST', 'localhost'); define('DBUSER', 'root'); define('DBPASS', ''); define('DBNAME', 'your_dbname');
And then use in your scripts:
<?php require_once('config.php'); $conn = mysql_connect(DBHOST, DBUSER, DBPASS) or die('Could not connect to database server.'); mysql_select_db(DBNAME) or die('Could not select database.'); ...
Assuming your config.php is in the same directory as your script.
Martin bean
source share