Estoy creando una base de datos para almacenar el contenido de unos .csv, la base de datos va asi:
Código:
Googleando me tope con un codigo que copia los datos del .csv a la bd, luego de modificarlo para adaptarlo a mi bd quedo asi:tlf_av bigint(20) central text empresa text cola text tipo_av text cuadrilla text nombre text apellido text estado text nom_area text hora timestamp uni_n text cc/cd text pc/pd text asd text p_local text fuente text fecha timestamp dias_pend text rango text idbigint(20) unsigned AUTO_INCREMENT
Código:
Obviamente me conecto a la base de datos y todo eso previo a ejecutar el fopen, pero me tira el siguiente error:$fp = fopen ('c:/captura.csv', 'r'); while ($data = fgetcsv ($fp,1000,'^')){ $insertar="INSERT INTO averias(tlf_av,central,empresa,cola,tipo_av,cuadrilla,nombre,apellido,estado,nom_area,hora,uni_n,cc/cd,pc/pd,asd,p_local,fuente,fecha,dias_pend,rango) VALUES ('$data[0]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]','$data[7]','$data[8]','$data[9]','$data[10]','$data[11]','$data[12]','$data[13]','$data[14]','$data[15]','$data[16]','$data[17]','$data[18]','$data[19]');"; mysql_query($insertar) or die(mysql_error()); echo "$insertar ok <br />"; } fclose($fp);
Código:
Y continua el Undefined offset hasta 19 (o sea de 2 a 19) ademas de:Notice: Undefined offset: 2 in C:\wamp\www\averias\guardar_captura.php on line 10
Código:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/cd,pc/pd,asd,p_local,fuente,fecha,dias_pend,rango) VALUES ('2814451361;8169;CAN' at line 1