Hi.

I have an Excel Spreadsheet with 25,000+ records to be imported into a database table.

I already re-sorted the columns to match my database fields, however when I tried exporting as a CSV to import via PHPMyAdmin, I got a puzzling error, "Invalid field count in CSV input on line 1."

Puzzling because I had the correct number of columns! So I'm chalking that up to some hidden Excel formatting.



Anyways...

So some googling later I found myself here, and learnt about "LOAD DATA INFILE".

How exactly do I use that function?

I saved and uploaded the data as a tab-delimited txt file, then ran a file called "load-data.php" with the following;


Code PHP:
<?php
// Connect to Database
	@ include($_SERVER['DOCUMENT_ROOT'] .'/Hidden/DatabaseInfo.php');
	@ mysql_connect($db_Host,$db_Username,$db_Password);
	@ mysql_select_db($db_Database) or die("Error.");
 
// Load Data from Text File
	LOAD DATA INFILE '/home/username/public_html/Database.txt';
 
// Dis-connect from Database
	@ mysql_close();
?>

This gave me a syntax error though;

Parse error: syntax error, unexpected T_STRING in /home/username/public_html/load-data.php on line 8
What am I doing wrong?