Hola Cluster:
ya hice la prueba con el COUNT pero tengo el mismo problema al querer meter el mismo archivo me respeta la condicion solo para unas lineas del archivo, es decir , que inserta los registros aun sabiendo que estan en la base de datos.
el codigo nuevo es el siguiente :
Código PHP:
<?php
$dir = opendir('ARCHIVOS_BD');
while(false !== ($file = readdir($dir))) {
if (($file != ".") and ($file != "..")){
$Nom_arch = fopen("ARCHIVOS_BD/".$file,"r");
while(!feof($Nom_arch)){
$cadena = fgets($Nom_arch,4096);
$x = split('[,]',$cadena);
if (($x[9] >= 1) and ($x[9] <= 3)){
$tabla = "TTAA".$x[0];
}
$estacion=0;$hoy="";$hora2="";$ps=0;$pp=0;$hgt=0;$tt=0;$td=0;$dd=0;$ff=0;$bloque=0;
$fecha = split('["]',$x[1]);
$hora = split(' ',$fecha[1]);
$ps = round($x[2]);
$pp = round($x[3]);
$hgt = round($x[4]);
$tt = $x[5];
$td = $x[6];
$dd = $x[7];
$ff = $x[8];
$bloque = round($x[9]);
$estacion = $x[0];
$fecha2 = $hora[0];
$dia = split('[- ]',$fecha2);
$hoy = $dia[0].$dia[1].$dia[2];
$hora2 = $hora[1];
$link = mysql_connect("localhost","root","admin");
mysql_select_db("RADIOSONDEO",$link);
$sentencia = "select COUNT(*) from $tabla where Estacion = $estacion and Fecha = $hoy and Hora = $hora2 and PS = $ps and PP = $pp and HGT = $hgt and TT = $tt and TD = $td and DD = $dd and FF = $ff and Bloque = $bloque";
$result = mysql_query($sentencia,$link);
if (mysql_result($result,0) > 0){
echo "Los datos ya existen <br>";
}
else{
echo "Introduciendo los datos <br>";
$sql = "INSERT INTO $tabla (Estacion,Fecha,Hora,PS,PP,HGT,TT,TD,DD,FF,Bloque)";
$sql .="VALUES ($x[0],'$hora[0]','$hora[1]',$x[2],$x[3],$x[4],$x[5],$x[6],$x[7],$x[8],$x[9])";
mysql_query($sql);
}
}
}
}
closedir($dir);
?>
no se por que solo en algunos casos cumple la condicion.
no se cual sea el problema.
gracias por tu apoyo.