Jump to content

Recommended Posts

** 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 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
Link to comment
https://forums.phpfreaks.com/topic/5081-help-with-load-data-local-infile-please/
Share on other sites

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....?
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.