Getting below error:
Warning: fopen(detail.csv) [function.fopen]: failed to open stream: No such file or directory in C:\xampp\htdocs\hindi\import_file.php on line 28
Warning: fgetcsv() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\hindi\import_file.php on line 29
Column count doesn't match value count at row 1
Need suggestions
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" enctype="multipart/form-data" method="post">
<strong>Import file:</strong><input type="file" name="uploadedfile"/>
<input type="submit" name="submit" value="submit"/>
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
include('db_hindi.php');
$file = $_FILES['uploadedfile']['name'];
$target_path="upload/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path);
$chk_ext = explode(".",$file);
if(strtolower($chk_ext[1]) == "csv")
{
$filename = $_FILES['uploadedfile']['tmp_name'];
$handle = fopen($file, "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$sql = "INSERT into tbl_hindi(num,address,name,father,state,city,gender,mobile,dob,namdan_date,file,mobile1,english_name,abbr) values('$data[0]','$data[1]','$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]')";
mysql_query($sql) or die(mysql_error());
}
fclose($handle);
echo "Successfully Imported";
}
else
{
echo "Invalid File";
}
}
?>