|
Thursday, 22 July 2010 12:21 |
// same mysql connection file for development and production, or more servers
// can you use the global $_SERVER['HTTP_HOST'] to identify your current active server, simple huh??
// this simple scrip identify your server by address
// if you want more serves, just add a elseif clause
//first - your development server
if ($_SERVER['HTTP_HOST'] == "127.0.0.1")
{
$hostname_content = "localhost";
$database_content = "YOUR_DATABASE";
$username_content = "YOUR_USER";
$password_content = "YOUR_PASS";
$conn = mysql_pconnect($hostname_content, $username_content, $password_content) or trigger_error(mysql_error(),E_USER_ERROR);
}
//second- your production server
else
{
$hostname_content = "YOUR_PRODUTION_SERVER";
$database_content = "YOUR_PRODUCTION_DATABASE";
$username_content = "YOUR_PRODUCTION_USER";
$password_content = "YOUR_PRODUCTION_PASS";
$conn = mysql_pconnect($hostname_content, $username_content, $password_content) or trigger_error(mysql_error(),E_USER_ERROR);
}
?>
 Read more: |