$fp = fopen("$form_data1", "r");
$flatfile = fread($fp, filesize("$form_data1"));
fclose($fp);
for ($i = 1; $i <= 10; $i++) {
$flatfile = ereg_replace(" {3}", " ", $flatfile);
}
$csv = ereg_replace(" {2}", ", ", $flatfile);
$csv1 = str_replace(chr(10), chr(10)."$season_id,", $csv);
$csv2 = str_replace(chr(10), chr(10)."$league_id,", $csv1);
$temp1 = str_replace(chr(10), chr(10)."$team1,", $csv2);
$temp = str_replace(chr(10), chr(10)."$team2,", $temp1);
$fp = fopen("$form_data1", "w+");
fwrite($fp, $temp);
fclose($fp);
$fp = fopen("$form_data1", "w+");
fwrite($fp, $temp);
fclose($fp);
$game_id_sql = "SELECT MAX(id) AS game_id FROM boxscore";
$game_result = mysql_query($game_id_sql);
$game_row = mysql_fetch_assoc($game_result);
$game_id = ",$game";
$data2 = file("$form_data1");
for($i=0;$i<count($data2);$i++)
{
$data2[$i] = "$game_id, " . $data2[$i];
}
$data2 = implode('\n\r', $data2);
$fp = fopen("$form_data2", "w+");
fwrite($fp, $data2);
fclose($fp);
$result = mysql_db_query('nbalive' ,"LOAD DATA LOCAL INFILE '$form_data1' INTO TABLE stats FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 5 lines") or die(mysql_error());
I need to add that code to this code.