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. Quote 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? Quote 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? Quote 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. Quote 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? Quote 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)? Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/3784-mysql-load-command/#findComment-13833 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.