I have tried everything that I can think of, but for some reason I cannot get this to work.
I have a piece of PHP code that loads a locally stored CSV file into a MySQL database. It works perfectly in one script:
$query = 'LOAD DATA LOCAL INFILE \''.$arp_input.'\' INTO TABLE arp_import FIELDS TERMINATED BY \',\' OPTIONALLY ENCLOSED BY \'"\' LINES TERMINATED BY \'
\' (not_used,account_number,check_serial,issue_date,amount,transaction_code,additional_text)';
However, I need to do the same thing (load a CSV) in another script that does essentially the same thing, but generates a different format. Here is the query:
$query = 'LOAD DATA LOCAL INFILE \''.$ap_input.'\' INTO TABLE ap_import FIELDS TERMINATED BY \',\' OPTIONALLY ENCLOSED BY \'"\' LINES TERMINATED BY \'
\' (account_number,check,paiddate,amount)';
But when I run the second script with the above query, I get this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'check,paiddate,amount)' at line 1
When I take out the field listing at the end of the second query, it only imports ONE line from the file and that is it, even when I tried the delimiter, , and both .
I have tried everything that I can think of. These two PHP scripts are running on the same server and they are both accessing the same remote MySQL server. What am I missing here?