LOAD DATA INFILE PHP/MySQL
Good afternoon
I'm trying to use PHP to transfer data from a CSV file into a MySQL Database. The code I have so far is:
$insert_query = "
LOAD DATA LOCAL INFILE 'sample.csv'
INTO table tblUncovered
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(headcode, booked);
"
if (!mysqli_query($insert_query, $conn)) {
echo "Can't insert student record : " . mysql_error($conn);
}
else {
echo "You have successfully insert records into student table";
}
Unfortunately, it doesn't seem to be working. If I comment out the last bit (If mysql_query onwards) the page will load, albeit do nothing. But when I include those lines, all I get is that 'This page isn't working'.
I've even tried using a file with just two rows and two fields and it won't have it.
Any ideas why?
Thanks Chris