PHP: Read data from a delimited file

$fin = fopen(“address.txt”, “rb”);

$row = 0;

while ($data = fgetcsv($fin, 2000, “,”);

{

$mm = count($data);

$row++;

$categories = $data[1]; $FirstName = $data[2];……

$sql = “insert into address (categories, FirstName) values (”$categories”, ”$FirstName”);

$result = mysql_query($sql);

$error_string = mysql_error();

$no_recs = mysql_affected_rows();

}

fclose($fin);

mysql_free_result($result);

mysql_close($connection);