You could store the connection details in any number of formats. The easiest being a php file which doesn't output anything:
<?php
$mysql = array
(
'host' => 'localhost',
'user' => 'mysql_user',
'pass' => 'password',
'db' => 'database_name'
);
if(!isset($mysqlconn) || !is_resource($mysqlconn))
{
$mysqlconn = mysql_connect($mysql['host'], $mysql['user'], $mysql['pass']);
if(!$mysqlconn)
{
throw new Exception ('Unable to connect to MySQL host.');
}
if(!mysql_select_db($mysql['db']))
{
throw new Exception ('Unable to select database.');
}
}
Then include that file in any php file you want mysql access to:
<?php
try
{
include_once('mysql_connect.php');
}
catch(Exception $e)
{
// There was an error connecting to the database. Now, just show an error; however,
// You probably want to die() or exit() after echoing the error.
echo '<p>' . $e->getMessage() . '</p>';
}
After that you can run queries using mysql_query() as you normally would.