2012-09-19 68 views
0

這有什麼線LOAD DATA查詢錯誤

$load ="LOAD DATA INFILE $inputFile INTO TABLE $tableName FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES"; 

echo $load; 

mysql_query($load); 

回聲結果是問題;

LOAD DATA INFILE appendpb.csv INTO TABLE appendpb_csv FIELDS TERMINATED BY ',' LINES TERMINATED BY ' ' IGNORE 1 LINES 

錯誤是;

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 'appendpb.csv INTO TABLE appendpb_csv FIELDS TERMINATED BY ',' LINES TERMINATED B' at line 1 

回答

2

按照MYSQL LOAD DATA Reference它應該有大約輸入文件的單引號:

$load ="LOAD DATA INFILE '$inputFile' INTO TABLE $tableName FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES"; 

最終尋找喜歡這個

LOAD DATA INFILE 'appendpb.csv' INTO TABLE appendpb_csv FIELDS TERMINATED BY ',' LINES TERMINATED BY ' ' IGNORE 1 LINES 

假設文件的路徑是正確的。

+0

嘿,謝謝一噸JLC007。這解決了它! – user1407430