Page 1 of 1
Import Text Files
Posted: Mon Feb 07, 2005 6:43 am
by Stelios
Hi there,
What I want to do is to import a text file into a mysql db. What I mean is that instead inputing the whole text directly into the db I want to input the name of the file and then when I call it from the script to show me the contents of the file instead of its name. I understand that this is possible, but could someone please help me?
Thanks a lot!

Posted: Mon Feb 07, 2005 6:49 am
by djot
-
Confusing description of what you need...
Do you want to store the text files data in the database?
Or just the filename?
Or whatever? :)
djot
-
Posted: Mon Feb 07, 2005 6:52 am
by Stelios
just the filenames but then be able to retrieve the content as well
Posted: Mon Feb 07, 2005 9:06 am
by feyd
So you want the file's contents returned when you perform a query.. in that query? The only way it could work is having the database create a temporary table to store off the content just before returning... but that's a pointless waste of memory and speed. It should be faster and easier to just load the file's contents immediately following the query once you know the filename.
Posted: Mon Feb 07, 2005 10:14 am
by Stelios
What I mean anyway, is that I want to just load the valu of the file into the database just by inserting its file name and without having to type the whole content...I dont know if am getting understood...
Posted: Mon Feb 07, 2005 10:16 am
by feyd
type the whole content?

file_get_contents() will load the data for you, you just have to insert the data it returns.. I don't see the difficulty.
Posted: Fri Feb 11, 2005 9:58 am
by rdionne1187
if you want the file line by line, if that would be easier, you could use file() but that returns the file in an array, so the code could get a little beefy

and i dont like arrays that much
Posted: Sat Feb 12, 2005 12:07 am
by n00b Saibot
I think he just wants the contents of file loaded into db. just that.
i suggest you install phpMyAdmin and use the option for loading test files
into db
