Jump to content


Photo

Help with LOAD DATA (LOCAL) INFILE Please


  • Please log in to reply
1 reply to this topic

#1 Humpty

Humpty
  • Members
  • PipPipPip
  • Advanced Member
  • 132 posts

Posted 16 March 2006 - 03:30 AM

** 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:
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', '', '');

This is the line that the code keeps stuffing up at:
$result = mysql_db_query('$user',"LOAD DATA INFILE '" . $uploaddir . "/" . $ulfilename . "' INTO TABLE newhardware FIELDS TERMINATED BY ',' ENCLOSED BY '\''");
$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 help

Any 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
- Humpty
  #> Where does the light go when it goes out?

#2 Humpty

Humpty
  • Members
  • PipPipPip
  • Advanced Member
  • 132 posts

Posted 16 March 2006 - 04:13 AM

ah-ha

Found 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....?
- Humpty
  #> Where does the light go when it goes out?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users