Saludos! Este es mi primer post, el problema que tengo es el siguiente:
Notice: Undefined offset: 3 in C:\xampp\htdocs\xampp\cert\csvimport06.php on line 7
Notice: Undefined offset: 2 in C:\xampp\htdocs\xampp\cert\csvimport06.php on line 7
Notice: Undefined offset: 1 in C:\xampp\htdocs\xampp\cert\csvimport06.php on line 7
Notice: Undefined offset: 3 in C:\xampp\htdocs\xampp\cert\csvimport06.php on line 7
Notice: Undefined offset: 2 in C:\xampp\htdocs\xampp\cert\csvimport06.php on line 7
Notice: Undefined offset: 1 in C:\xampp\htdocs\xampp\cert\csvimport06.php on line 7
Notice: Undefined offset: 3 in C:\xampp\htdocs\xampp\cert\csvimport06.php on line 7
Notice: Undefined offset: 2 in C:\xampp\htdocs\xampp\cert\csvimport06.php on line 7
Notice: Undefined offset: 1 in C:\xampp\htdocs\xampp\cert\csvimport06.php on line 7
No database selected
Y aqui va el codigo!:
<?php
$file = "import.csv";
if (($handle = fopen($file, "r")) !== FALSE) {
if(!filesize($file)){echo "File is empty.\n";exit;}
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
list($F1, $F2, $F3, $F4) = $data;
$SQL[] = sprintf("INSERT into students (field1, field2, field3, field4) VALUES ('%s', '%s', '%s','%s')", $F1, $F2, $F3, $F4);
}
fclose($handle);
}else{
echo "Can't open file";
exit();
}
$conn = mysql_connect("localhost", "XXX", "XXX", "XXX");
mysql_select_db("students");
foreach($SQL as $sql){
mysql_query($sql, $conn) or die(mysql_error());
}
?>
Espero que me podais exar una mano!! Gracias!