Humpty Posted March 16, 2006 Share Posted March 16, 2006 ** SOLVED **G'day again oh great PHPers.I have written code that uploads a file to the server but now I can't use the LOAD DATA (LOCAL) INFILE command to import it.I have seen an example and even looked in the manual but it just ain't working.This is an example of the file contents:[code]INSERT INTO newhardware VALUES('', 'Cables & Connectors', 'Others', ' ', 'CBLVGA', 'ALTECH', 'CB-MT', 'VGA Extension cable - 1.8M', 'VGA Extension cable 1.8M', '6', '1', '2.73', '3', '25', '170', '240', '0.00102', '0.05', 'N/A', ' ', 'OEM Cables', '6', '2', '1423', '', '');INSERT INTO newhardware VALUES('', 'Cables & Connectors', 'Others', ' ', 'CBLSERIAL-D9', 'ALTECH', 'WC7534', 'Serial Cable - D9F to D9M, 1.8m long', 'Serial Cable - D9F to D9M (9-pin female to 9-pin male connection), 1.8m long', '16', '1', '7.27', '8', '25', '160', '220', '0.00088', '0.05', 'N/A', ' ', 'OEM Cables', '16', '2', '1426', '', '');[/code]This is the line that the code keeps stuffing up at:[code]$result = mysql_db_query('$user',"LOAD DATA INFILE '" . $uploaddir . "/" . $ulfilename . "' INTO TABLE newhardware FIELDS TERMINATED BY ',' ENCLOSED BY '\''");[/code]$User = the username for the database$uploaddir . "/" . $ulfilename = ../filestores/oznetttest.txt (which is correct path)But it always dies. (The code used to have a 'or die' as well but i removed it to see if it would helpAny ideas?(alternatively I am quite happy to load the file one line of code at a time and query each line individually, (but no idea how to retrieve 1 line at a time))Thanks Quote Link to comment https://forums.phpfreaks.com/topic/5081-help-with-load-data-local-infile-please/ Share on other sites More sharing options...
Humpty Posted March 16, 2006 Author Share Posted March 16, 2006 ah-haFound how to do it line-by-line in the manual and am happy with results, (sure it'll take longer but it works:Once again...I tried adding the code here but then I get a page telling me that access is forbidden..so no code to show.MODERATORS: Could it have something to do with the fact that both times this has happened The code has included miscelanouse file() compands? like fopen() and fread() etc....? Quote Link to comment https://forums.phpfreaks.com/topic/5081-help-with-load-data-local-infile-please/#findComment-18016 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.