Help: I can’t import information from a URL to my bank

Asked

Viewed 35 times

1

Gentlemen I am trying to collect information from a URL and send to my DB, in the url the information comes all mixed, with the scritp I can already organize them as follows:

[1] => Array
    (
        [PROTOCOLO] => 1234
        [FILA] => Rede
        [STATUS] => ABERTO
        [DT_ABERTURA] => 17/04/2018 16:10:34
        [SERVICO] => Registro de Falhas
        [REGIONAL] => EUA
        [LOCALIDADE] => IF
        [DESCRICAO] => Falha na placa 
        [INTERROMPEU] =>  
        [QNT_CLIENTE] => 0
        [OBS] => OG: 1234 [ABERTURA]

But I can’t collect this information and release it on DB, I need help. The same at the end of the data organization returns the error Warning: mysqli_query() expects at least 2 Parameters, 1 Given in C: xampp htdocs test.php on line 65.

Line 65 is mysqli_query("INSERT INTO

Follows my code.

<?php



//function dados() {

$url = 'http://pordesemml.arecom.com.br/api/cor/teste.php?usuario=testes&senha=teste';

            $contents = file_get_contents($url);
            $contents = utf8_encode($contents);
            $results = json_decode($contents, true);
           echo "<pre>";
            print_r($results); 


            foreach ($results as $key => $value) { //$results é o conteudo que veio daquela url
            mysqli_connect (salvaBancoOG($value)); //ele pega cada linha armazena no $value e envia para uma função com o nome salvaBancoOG

            } 

      // }

 #Include do arquivo de configurações

function salvaBancoOG($value) {


    $data_registro = date_create('now')->format('Y-m-d H:i:s'); //data e hora atual
    $data_fim =  "0000-00-00 00:00:00";




     if ($value[PROTOCOLO] == null)
         $value[PROTOCOLO] = " ";
     if ($value[FILA] == null)
         $value[FILA] = " ";
     if ($value[STATUS] == null)
         $value[STATUS] = " ";
     if ($value[DT_ABERTURA] == null)
         $value[DT_ABERTURA] = " ";
     if ($value[SERVICO] == null)
         $value[SERVICO] = " ";
     if ($value[REGIONAL] == null)
         $value[REGIONAL] = " ";            
     if ($value[LOCALIDADE] == null)
         $value[LOCALIDADE] = " ";  
     if ($value[DESCRICAO] == null)
         $value[DESCRICAO] = " ";   
     if ($value[INTERROMPEU] == null)
         $value[INTERROMPEU] = " ";
     if ($value[QNT_CLIENTE] == null)
         $value[QNT_CLIENTE] = " ";         
     if ($value[OBS] == null)
         $value[OBS] = " "; 


 }      

         mysqli_query("INSERT INTO 'diario' (`protocolo`, `fila`, `status`, `dt_abertura`, `servico`, `regional`, `localidade`, `descricao`, `massiva`, `qnt_cliente`, `obs`, `id`) 
         VALUES  ('12345678','Tx','Em Aberto','2018-04-17 00:00:00','ula','ula','escrição teste','1','10','deletar','''','''','''','''','NULL');"); //envia para o banco de dados



?>

My connection to the Bank is through a variable:

$conn= mysqli_connect($local_serve, $usuario_serve, $senha_serve, $banco_de_dados) or die ("O servidor não responde!");
  • 2

    Do not put the code image. Edit your question and write the code of a Ctrl+V in your question. Images do not help much in this case

  • Hello, Rodrigo! Welcome. As told by @hugocwl, edit your question and enter the code. Unfortunately images are harder to read and the OS and Google search cannot index the code within it.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.