I'm having an issue with CSV import to MySQL database:
<div style="border:1px dashed #333333; width:300px; margin:0 auto; padding:10px;">
<form name="import" method="post" enctype="multipart/form-data">
<input type="file" name="file" /><br />
<input type="submit" name="submit" value="Submit" />
</form>
<?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)
{
$name = $filesop[0];
$email = $filesop[1];
$sql = mysql_query("INSERT INTO selleruser (emailid, pass) VALUES ('$name','$email')");
$c = $c + 1;
}**
if($sql){
echo "You database has imported successfully. You have inserted ". $c ." recoreds";
}else{
echo "Sorry! There is some problem.";
}
}?>
</div>
I'm getting this error:
Undefined offset: 1 at thish line $email = $filesop1;