query to upload csv file to table error
I am using a webpage that simply runs this query (so client can use it).
It is supposed to empty the table (the theory being that it resets the auto-incrementing ID to 1 again - which it doesn't!).
Then it should take the file off the clients desktop, upload it to the server and put it into the table. There's something wrong with the syntax of the second query yet it is EXACTLY the same, apart from the file location, as what DOES work when you use phpmyadmin.
Tired......look forward to your help. Thanks. Incidentally probably don't need the TRUNCATE query if I use REPLACED in the second one.
Error given is ....unexpected T_CONSTANT_ENCAPSED_STRING
// Run query
mysql_query("TRUNCATE TABLE `books`", $eg_objConn1);
mysql_query("LOAD DATA LOCAL INFILE 'C:/Documents and Settings/Jon/Desktop/anita.csv' REPLACE INTO TABLE 'books' FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n' IGNORE 1 lines", $eg_objConn1);
Re: query to upload csv file to table error
You didn't escape the double quotes inside the string, ENCLOSED BY '"'
Here is the correct query.
|All times are GMT +5.5. The time now is 05:18.|