Hi,
I found this script to import a txt to a MySQL table. In my case, the table is called sperr001, and the txt file is called HSD.txt with CSV format (under c:\php).
<?php
include 'db_connection.php';
include 'header.htm';
## CSV file to read in ##
$CSVFile = 'C:\\php\\HSD.txt';
mysql_query('LOAD DATA LOCAL INFILE 'C:\\php\\HSD.txt' INTO TABLE sperr001 FIELDS TERMINATED BY "," LINES TERMINATED BY "\\r\\n";') or die('Error loading data file.<br>' . mysql_error());
## Close database connection when finished ##
mysql_close($conn);
?>
After I run this code, my browser went blank (no message at all) and my DB table was not updated with the data in the txt file.
What did I do wrong?
Should I or should I not include the directory of the file? When I don't include it, it says error file not found.
Please help!!
I found this script to import a txt to a MySQL table. In my case, the table is called sperr001, and the txt file is called HSD.txt with CSV format (under c:\php).
<?php
include 'db_connection.php';
include 'header.htm';
## CSV file to read in ##
$CSVFile = 'C:\\php\\HSD.txt';
mysql_query('LOAD DATA LOCAL INFILE 'C:\\php\\HSD.txt' INTO TABLE sperr001 FIELDS TERMINATED BY "," LINES TERMINATED BY "\\r\\n";') or die('Error loading data file.<br>' . mysql_error());
## Close database connection when finished ##
mysql_close($conn);
?>
After I run this code, my browser went blank (no message at all) and my DB table was not updated with the data in the txt file.
What did I do wrong?
Should I or should I not include the directory of the file? When I don't include it, it says error file not found.
Please help!!