atualização do BD a aprtir de 1 txt
estou usando o código abaixo para capturar os dados de um arquivo txt e alimentar o BD, mas não está funcionando...Não apresenta nenhum erro, apenas fica enviando indefinidamente sem terminar e não atualiza o BD.
> if(isset($_FILES["arquivo"])){//$destino = ""; $table="nomedatable";$nome1 = $_FILES["arquivo"]["name"];$ext = explode(".", $nome1);$ext = array_pop($ext);$tmp = $_FILES["arquivo"]["tmp_name"];$nomenovo = "nome.txt";move_uploaded_file($tmp,$nome1); rename("$nome1", "$nomenovo");require "cone.php"; $file = fopen("nome.txt","r"); while (!feof($file)){$linha = fgets($file,421); // total$rf = substr($linha,0,8); // 8 $ativ = substr($linha,8,48); // 40$rs = substr($linha,48,108); // 60$cid = strtoupper(substr($linha,108,138)); // 30$end = substr($linha,138,198); //60$tel = substr($linha,198,258); // 60$site = strtolower(substr($linha,258,298)); // 40$uf = strtoupper(substr($linha,298,300)); // 2$anuncio = substr($linha,300,340); // 40$ativo = substr($linha,340,341); // 1$tipo = substr($linha,341,351); // 10$fax1 = substr($linha,351,381); // 30$email = substr($linha,381,421); // 40$sql = "SELECT rf from $table where rf='$rf'"; $query = mysql_query($sql);$retorn = mysql_num_rows($query);if ($retorn > 0) {if ($fax1 > 2){ $fax = $fax1; } else { $fax = ''; }$sqla = "UPDATE $table SET rf = '$rf', ativ = '$ativ', rs = '$rs', cid = '$cid', end = '$end', tel = '$tel', site = '$site', uf = '$uf', anuncio = '$anuncio', ativo = '$ativo', tipo = '$tipo', fax = '$fax', email = '$email' where rf='$rf'";$querya = mysql_query($sqla) or die("Ocorreu um erro.2");} else {if ($fax1 > 2){ $fax = $fax1; } else { $fax = ''; } $sqla = "INSERT INTO $table SET rf = '$rf', ativ = '$ativ', rs = '$rs', cid = '$cid', end = '$end', tel = '$tel', site = '$site', uf = '$uf', anuncio = '$anuncio', ativo = '$ativo', tipo = '$tipo', fax = '$fax', email = '$email'";$querya = mysql_query($sqla) or die ("Ocorreu um erro.3: ".mysql_error());} // fecha o else do ($retorn > 0)} //fecha whileunlink("nome.txt"); $res = mysql_query("SELECT id FROM $table where rs = ''");while($res1 = mysql_fetch_array($res)){$rb = $res1['id']; $sel = mysql_query("DELETE FROM $tableWHERE id='$rb'");}mysql_close();} // fecha issetDiscussão (1)
Carregando comentários...