Im trying to import a .CVS file with First name and last name. But what it only does is import it to just one column in my database. And i get Notice: Undefined offset: 1 in ..insertimportres.php on line 91
and that is $enamn = $filesop[1];
that is complains on.
CVS/Excel
PHP
<?php
include ("connection.php");
if(isset($_POST["submit"]))
{
$file = $_FILES['file']['tmp_name'];
$handle = fopen($file, "r");
$c = 0;
while(($filesop = fgetcsv($handle, 1000, ",")) !== false)
{
$fnamn = $filesop[0];
$enamn = $filesop[1];
$sql = mysql_query("INSERT INTO kandidater (fnamn, enamn) VALUES ('$fnamn','$enamn')");
$c = $c + 1;
}
if($sql){
echo "You database has imported successfully";
}else{
echo "Sorry! There is some problem.";
}
}
</div>