2
I am creating a script to execute procedures in the database of some customers, I have the following arrays with the credentials of each:
$hosts["Cliente1"] = array("ip"=> "ip_do_cliente", "usuario" => "usuario","senha" => "12345","base" => "conadmin","porta" => "3306");
$hosts["Cliente2"] = array("ip"=> "ip_do_cliente", "usuario" => "usuario","senha" => "12345","base" => "conadmin","porta" => "3306");
$hosts["Cliente3"] = array("ip"=> "ip_do_cliente", "usuario" => "usuario","senha" => "12345","base" => "conadmin","porta" => "3306");
i make a foreach to connect in each of them, this way:
foreach ($hosts as $key=>$host)
{
$conn = mysqli_connect($host['ip'], $host['usuario'], $host['senha'], $host['base'], $host['porta']);
}
In case of success, I do a query to save in my database,:
$data = date('d/m/Y H:i:s');
$ip_cliente = $host['ip'];
$cliente = ????;
$mensagem = 'Teste Executado com sucesso!';
$query = sprintf("INSERT INTO pbx_teste_permissao(ip_cliente, data_teste, mensagem)"
. "values('%s','%s','%s', '%s')",$ip_cliente, $data, $cliente, $mensagem);
pg_query($query);
i wanted to store also the client name, as I could return from the foreach the client name and fill in the variable $client ?
there’s only one thing I need to go along with you, that Insert comes inside the foreach or outside?
– Julio Henrique
he goes inside the foreach, sorry when I went to put the code here I did not heed the key detail.
– Henrique
of good my answer works for you then, if it had not been necessary an array,
– Julio Henrique
got it ! Thank you very much Julio !
– Henrique