I'm sorry but I had to rewrite all my question because it was not being objective enough to make me understand, when I omit code as it was the previous case is not to hide something is just to be able to perceive what they respond to me within my limitations of programming, in any case as soon as the platform is ready I will make it available online.
In this first file will be available the variables to be able to be changed to make the connections between the 3 servers the demo is for server 1.
#/pasta/config.php
<?PHP
//Atenção ao configurar este ficheiro pois é igual para os 3 servidores
//e terá que ter em mente em que servidor o esta a configurar
//porque tem que descomentar o $serverip correspondente e entre as aspas colocar o seu ip interno de sua rede
//e em $dbL colocar entre as aspas o numero correspondente ao servidor que escolheu 1, 2 ou 3.
$dbL = "1";// Que servidor é este? 1, 2 ou 3.
$serverip1 = "10.0.0.101"; // Ip interno Mysql se for o servidor 1
$db_porta1 = "3306"; // Porta Mysql servidor 1
$db_user1 = "dns"; // Utilizador Mysql servidor 1
$db_password1 = "123456"; // Senha Mysql servidor 1
$db_name1 = "dns"; // Nome base dados Mysql servidor 1
//$serverip2 = "10.0.0.102"; // Ip interno Mysql se for o servidor 2
$db_porta2 = "3306"; // Porta Mysql servidor 2
$db_user2 = "dns"; // Utilizador Mysql servidor 2
$db_password2 = "123456"; // Senha Mysql servidor 2
$db_name2 = "dns"; // Nome base dados Mysql servidor 2
//$serverip3 = "10.0.0.103"; // Ip interno Mysql se for o servidor 3
$db_porta3 = "3306"; // Porta Mysql servidor 3
$db_user3 = "dns"; // Utilizador Mysql servidor 3
$db_password3 = "123456"; // Senha Mysql servidor 3
$db_name3 = "dns"; // Nome base dados Mysql servidor 3
?>
The next 3 files are updated every 60 seconds and the ips have already been checked before entering the servers.
#/pasta/connect/ipserver1.php
<?PHP $s_ipserver11 = "xx.246.142.235";?>
#/pasta/connect/ipserver2.php
<?PHP $s_ipserver22 = "xx.246.142.245";?>
#/pasta/connect/ipserver3.php
<?PHP $s_ipserver33 = "xx.246.142.255";?>
To not be doing 4 includes in all the files you need, I created the following one.
#/pasta/connect/ipservers.php
<?PHP
include_once("/pasta/config.php");
include_once("/pasta/connect/ipserver1.php");
include_once("/pasta/connect/ipserver2.php");
include_once("/pasta/connect/ipserver3.php");
?>
This will be the file of this question where I want to input 2 variables or not and output a third for each connection.
#/pasta/connect/convencao.php
<?PHP
include_once("/pasta/connect/ipservers.php");
//Se existir variável $serverip1 ler valor se não ler valor de $s_ipserver11 mas se existirem as duas ler sempre $serverip1 e responder em $ip1.
//Se existir variável $serverip2 ler valor se não ler valor de $s_ipserver22 mas se existirem as duas ler sempre $serverip2 e responder em $ip2.
//Se existir variável $serverip3 ler valor se não ler valor de $s_ipserver33 mas se existirem as duas ler sempre $serverip3 e responder em $ip3.
if( isset( $serverip1 ) and isset( $s_ipserver11 ) )
{
$ip1 = $serverip1;
}
else
{
if( isset( $serverip1 ) )
$ip1 = $serverip1;
if( isset( $s_ipserver11 ) )
$ip1 = $s_ipserver11;
}
if( isset( $serverip2 ) and isset( $s_ipserver22 ) )
{
$ip2 = $serverip2;
}
else
{
if( isset( $serverip2 ) )
$ip2 = $serverip2;
if( isset( $s_ipserver22 ) )
$ip2 = $s_ipserver22;
}
if( isset( $serverip3 ) and isset( $s_ipserver33 ) )
{
$ip3 = $serverip3;
}
else
{
if( isset( $serverip3 ) )
$ip3 = $serverip3;
if( isset( $s_ipserver33 ) )
$ip3 = $s_ipserver33;
}
$s_ipserver1 = $ip1;
$s_ipserver2 = $ip2; //Coloquei estas 3 variáveis para dar a entender o que preciso mas podem ser apagadas.
$s_ipserver3 = $ip3;
?>
Below are the various forms of linking to imply what I need.
Connection to server 1
#/pasta/connect/connectserver1.php
<?PHP
include_once("/pasta/connect/convencao.php");
$db_host1 = "$s_ipserver1:$db_porta1";
$db_link1 = mysql_connect($db_host1, $db_user1, $db_password1) or die (mysql_error ());
$db_connect1 = mysql_select_db($db_name1, $db_link1);
?>
Connection to server 2
#/pasta/connect/connectserver2.php
<?PHP
include_once("/pasta/connect/convencao.php");
$db_host2 = "$s_ipserver2:$db_porta2";
$db_link2 = mysql_connect($db_host2, $db_user2, $db_password2) or die (mysql_error ());
$db_connect2 = mysql_select_db($db_name2, $db_link2);
?>
Connection to server 3
#/pasta/connect/connectserver3.php
<?PHP
include_once("/pasta/connect/convencao.php");
$db_host3 = "$s_ipserver3:$db_porta3";
$db_link3 = mysql_connect($db_host3, $db_user3, $db_password3) or die (mysql_error ());
$db_connect3 = mysql_select_db($db_name3, $db_link3);
?>
Variables for connecting to the local server
#/pasta/connect/connectserverLsub.php
<?php
include_once("/pasta/connect/convencao.php");
$ipserver = 's_ipserver'. $dbL;
$porta = 'db_porta'. $dbL;
$user = 'db_user'. $dbL;
$password = 'db_password'. $dbL;
$name = 'db_name'. $dbL;
?>
Local server connection
#/pasta/connect/connectserverL.php
<?PHP
include_once("/rjpdns/connect/connectserverLsub.php");
$host = $$ipserver . ':'. $$porta;
$link = mysql_connect($host, $$user, $$password) or die (mysql_error ());
$db_connect = mysql_select_db($$name, $link);
?>
I hope this time to have exposed and improved my doubts.