The problem is that I have data that I'm importing some times contains commas in the field.
the CSV file is quote comma delimited and looks like this.
"field 1","field,2","field 3" etc...
notice that the second data set has a comma in it. this is normal and not the next field to be imported. How can I check for this and import all the data properly.
if ($file_handle) {
while (!feof($file_handle)) {
$line = fgets($file_handle);
$data = explode(",", str_replace('"', '',$line));
$date = explode(" ", $data[1]);
$swap_date = date('Y-m-d', strtotime($date[0]));
$query = "INSERT INTO tbltranslog VALUES ";
$query .= "(NULL,'".$data[0]."','".$swap_date."','".$data[2]."','".$data[5]."','".$data[6]."','".$data[35]."','".$data[37]."'),";
$query2 = substr($query, 0, -1);
echo $query;
if ($data[2] != "Amount") {
mysqli_query($link, $query2);
}
}
fclose($file_handle);
}