GET FILE is not saving result

1

I made this code with the intention of searching the data < strong> of this site (PUBLIC) and save in my DB. Here is the code:

<?php
//$arquivo=$_GET["file"];
$arquivo = 'http://portal.cgna.gov.br/files/abas/2017-10-02/painel_rpl/companhias/Cia_TAM_CS.txt';
include ("connect_db.php");
//$arquivo="apt.txt";//pega o nome do arquivo
@$meuArray = file($arquivo); //armazena na variavel $meuArray o arquivo
for ($n = 0; $n < count($meuArray); $n++) {

}//pega o número de linhas do arquivo e armazena em $n
@$abre = fopen($arquivo, "r"); //abre o arquivo
$file_name = explode(".txt", $arquivo);
$file_name = $file_name[0];
echo $file_name . "<BR><BR>";
for ($i = 0; $i < $n; $i++) {//le o arquivo linha por linha
    $le = fgetss($abre, 1024); // $le representa a linha inteira do arquivo
    $le = trim($le);
    if (strlen($le) >= 60) {
        $explo = explode(" ", $le);

        $desde = $explo[0];
        $ate = $explo[1];

        if ($ate == 'UFN') {
            $dias = $explo[5];
            $voo = $explo[6];
            $equip = $explo[7];
            $depX = $explo[8];
            $vel = $explo[9];
            $fl = $explo[10];

            $dep = substr($depX, 0, 4);
            $depTime = substr($depX, 4, 4);

            $route = explode($explo[10], $le);
            $routeX = explode(" SB", $route[1]);
            $route = $routeX[0];
            $arr = explode("EQPT/", $routeX[1]);
            $arrX = $arr[0];

            $arr = substr($arrX, 0, 2);
            $arrTime = substr($arrX, 2, 4);
        } else {
            $dias = $explo[2];
            $voo = $explo[3];
            $equip = $explo[4];
            $depX = $explo[5];
            $vel = $explo[6];
            $fl = $explo[7];

            $dep = substr($depX, 0, 4);
            $depTime = substr($depX, 4, 4);

            $route = explode($explo[7], $le);
            $routeX = explode(" SB", $route[1]);
            $route = $routeX[0];
            $arr = explode("EQPT/", $routeX[1]);
            $arrX = $arr[0];

            $arr = substr($arrX, 0, 2);
            $arrTime = substr($arrX, 2, 4);
        }
        $empresa = substr($voo, 0, 3);
        $cad = "INSERT INTO cgna (Desde,Ate,Dias,Empresa,Voo,Aeronave,Origem,Horario,Velocidade,FL,Rota,Destino,Chegada) VALUES('$desde','$ate','$dias','$empresa','$voo','$equip','$dep','$depTime','$vel','$fl','$route','$arr','$arrTime')";
        $cadastra = mysql_query($cad);
    }//fim do strlen
}//endfor

?>

The code is not saving the data in my DB. Can anyone help me please?

    
asked by anonymous 03.10.2017 / 03:36

0 answers