liltbobas Posted February 28, 2006 Share Posted February 28, 2006 I'm trying to build a script to load tab delimited text files into my database, but I can't get a working query. Here's what I got:$command = mysql_query ("LOAD DATA LOCAL INFILE '/file.txt' INTO TABLE electronics FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' (ITEM NUMBER, ITEM NAME, CATEGORY, SUB-CATEGORY, DESCRIPTION, WEIGHT, WHOLESALE PRICE, RETAIL PRICE, SHIPPING, HANDLING, CARRIER NAME, QUANTITY IN STOCK, IMAGE SMALL, IMAGE MEDIUM, IMAGE LARGE, DETAIL URL)");if ($command) { echo "<br>good"; } else { echo "<br>bad"; }It returns bad every time. Any suggestions? Thanks. Link to comment https://forums.phpfreaks.com/topic/3784-mysql-load-command/ Share on other sites More sharing options...
fenway Posted March 1, 2006 Share Posted March 1, 2006 What's with all the spaces in the column names? Link to comment https://forums.phpfreaks.com/topic/3784-mysql-load-command/#findComment-13172 Share on other sites More sharing options...
liltbobas Posted March 1, 2006 Author Share Posted March 1, 2006 i can't have spaces? Link to comment https://forums.phpfreaks.com/topic/3784-mysql-load-command/#findComment-13206 Share on other sites More sharing options...
wickning1 Posted March 1, 2006 Share Posted March 1, 2006 Correctomundo. Link to comment https://forums.phpfreaks.com/topic/3784-mysql-load-command/#findComment-13215 Share on other sites More sharing options...
liltbobas Posted March 2, 2006 Author Share Posted March 2, 2006 fixed spaces, still doesn't work. any other suggestions? Link to comment https://forums.phpfreaks.com/topic/3784-mysql-load-command/#findComment-13669 Share on other sites More sharing options...
wickning1 Posted March 3, 2006 Share Posted March 3, 2006 Try echoing mysql_error() after the query.Does mysqld have permission to read the file in question? Is the file on the database server (instead of the web server, if they're different)? Does the file use unix-style line feeds (\n)? Link to comment https://forums.phpfreaks.com/topic/3784-mysql-load-command/#findComment-13750 Share on other sites More sharing options...
liltbobas Posted March 3, 2006 Author Share Posted March 3, 2006 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 ''electronics'' at line 1 Link to comment https://forums.phpfreaks.com/topic/3784-mysql-load-command/#findComment-13833 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.