I have a form and when I hit submit, I need the data that I posted to be saved to a csv file. The code below generates a syntax error elsewhere in my script but I know the problem lies somewhere here. Can someone please explain my mistake?
//Store all data into variables ready to save
if (isset($_POST['submit'])) {
$ID = $_POST['gameID'];
$GameName = $_POST['gameName'];
$GameCost = $_POST['gameCost'];
$Days = $_POST['days'];
$Total = $_POST['total'];
$DateFrom = $_POST['reservationStart'];
$DateTo = $_POST['DateEnd'];
$StudentName = $_POST['studentName'];
//Saving the booking
$csv_file = 'loans.csv';
$csv_handle = fopen($csv_file,'a');
$csv_item = "\"$ID\",\"$GameName\",\"$GameCost\",\"$Days\",\"$Total\",\"$DateFrom\",\"$DateTo\",\"$StudentName\"
";
fwrite($csv_handle, $csv_item);
fclose($csv_handle);