Forum Moderators: coopster
if ($_SERVER['SERVER_NAME']=="localhost"
OR $_SERVER['SERVER_NAME']=="192.168.1.1"
OR $_SERVER['SERVER_NAME']=="192.168.1.2"){
//local host
$db_hostname = "localhost";
$db_username = "my_local_username";
$db_password = "my_local_password";
$db_database = "local_visitor";
$mysqli = new mysqli($db_hostname, $db_username, $db_password, $db_database);
} else {
//remote host
$db_hostname = "localhost";
$db_username = "my_remote_username";
$db_password = "my_remote_password";
$db_database ="remote_visitor";
$mysqli = new mysqli($db_hostname, $db_username, $db_password, $db_database);
}
($_SERVER['SERVER_NAME']=="localhost"would work since the ip addresses are given, but it will fail when removed AND not work if the two ip addresses are removed? Isn't the if control satisfied when the 1st OR operand evaluates to TRUE? But then it would never connect remotely?!?!
if ($_SERVER['SERVER_NAME']=="localhost")
{
//local host
$db_hostname = "localhost";
$db_username = "my_local_username";
$db_password = "my_local_password";
$db_database = "local_visitor";
$mysqli = new mysqli($db_hostname, $db_username, $db_password, $db_database);
}
else
{
//remote host
$db_hostname = "localhost";
$db_username = "my_remote_username";
$db_password = "my_remote_password";
$db_database ="remote_visitor";
$mysqli = new mysqli($db_hostname, $db_username, $db_password, $db_database);
}
printf('<br/><br/>'.$_SERVER['SERVER_NAME']);
printf('<br/><br/>'.$db_hostname); Your SERVER_NAME environment variable has nothing at all to do with your mySQL server name. Nothing. The fact that it populates it locally is just confusing you. :-)Something went click in my head, got it! And I see why the hosting service uniquely prefixes subscriber db names with a piece of our domain names. Ok, I'm good for now, thx!