I currently have an issue where when I attempt to insert data from a CSV file into a MySQL database using PHP I get an error that is caused by empty fields within the CSV file.

In each row of data that has at least one empty field, it produces an error and doesn't insert the whole row into the database due to the empty field(s).

I was wondering if anybody knows how to find each empty field within the CSV file and populate them before they are inserted ("0" for empty int fields and "N/A" for empty varchar fields) without going through the CSV file and filling in the data manually.

**Code for inserting the data into database**

```
foreach($gymarr as $row){
    $day = $row[0];
    $routine= $row[1];
    $time= $row[2];
    $type= $row[3];
    $run= $row[4];
    $weights= $row[5];
    $tally= $row[6];

$sqlinsert = "INSERT INTO Gym (day, routine, time, type, run, weights, tally) 
 VALUES ('$day', '$routine', $time, '$type', '$run', '$weights', tally)";

$result = $conn->query($sqlinsert);

```