Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT directory paths to table column 1

Status
Not open for further replies.

DLayzell

IS-IT--Management
Apr 27, 2005
29
CA
Good Day,

I am looking for a way to upload the paths of a directory full of files and folders (approx. 3-4 levels deep) on my website into a column of a MySQL table.

Currently, I am expecting to have to write a PHP script to take the paths into an array, and upload them that way, but I wondered if there were an easier way a guru might recommend to me.

Thanks to all for any input. Safe and speedy computing to you all.

Dave

=========================================
David Layzell, A+, Project+
=========================================
 
you don't need php as long as you know some way of simply listing the paths into a simple file

then you can use the LOAD DATA INFILE command

:)

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
Thank you for that!

This does seem like a much quicker way. I've created a table with two fields, one is ID, which is an autoincrement, and the other, FILE_PATH which is a VARCHAR.

I attempt this query, but I am not certain how to specify the column. Here's the syntax I use:

LOAD DATA INFILE 'file_name' INTO TABLE 'tbl_name'

This does create a number of records equal to the number of lines on my text file, but the data isn't uploaded into the FILE_PATH column. I must have to specify the column, but I get syntax errors when I do. Any advise?

=========================================
David Layzell, A+, Project+
=========================================
 
Nevermind, I've got it now!

I needed to specify the column name in parenthesis after the command, ex.:

LOAD DATA INFILE 'filename' INTO TABLE tablename (columnname);

Thank you so much for the help, r937! You've saved me a TON of time!

==========================================
David Layzell, A+, Project+
Computer Network Engineering Grad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top