PDA

Click to See Complete Forum and Search --> : Database as a txt file


SystemShock
Jul 29th, 2002, 05:26 PM
Hi,
I'm new to php and till now it was going pretty good till I encountered a problem. The database that I want to query appears as a txt file on the internet. I want to know how I can make/execute SQL queries using mysql on this db. Also how do I convert db's to txt files.

Thx.

Link to db : http://npaweb01.planetarion.com/botfiles/planet_listing.gz

The Hobo
Jul 29th, 2002, 05:38 PM
You can't use MySQL on a text file. It has to be a MySQL database. Unless I'm confused here.

SystemShock
Jul 29th, 2002, 05:59 PM
Forgive me. What I meant was how do I convert txt files into db's. Does the txt file have to be in a particular format?

I am currently using phptriad and it has phpmyadmin in it. I tried to use it to convert a txt file into a db but it keeps giving me an error.

Also, do I have to make the db manually first before I try to insert a txt file into it?

Thx.

phpman
Jul 30th, 2002, 09:42 AM
yes you have to make the db table first before you insert the info into it. it all depends on how the info is stroed in the txt file as how it goes into the table. what columns do you have? what rows will you have? a lot of factors goes into creating a DB table. you just can't insert a txt file and think things will be ok.

SystemShock
Jul 31st, 2002, 02:43 PM
Thx.

I did all that, made the table manually and even entered a couple of records just to be sure.

Whenever I try to insert a txt file into a table it gives me an error saying that some tmp file wasn't found. I am quite sure I've entered information such as seperator etc properly.

Btw I'm using phpmyadmin(which comes with phptriad) for doing all this.

Please help.

Thx.

cpradio
Jul 31st, 2002, 02:49 PM
To be honest it is best to write your own conversion tool. For example say your text file has the following format:

value01:value02:value03:value04
value11:value12:value13:value14

Where each new line is a new record and values are seperated by colons

What you would need to write is a php script that opens and reads that file line for line, exploding each line at the :, making an array of 4 values.

Then you use your pre-defined MySQL table that you built and give each field one of those four values, then go to the next line in the file.

The Hobo
Jul 31st, 2002, 03:12 PM
Originally posted by cpradio
To be honest it is best to write your own conversion tool. For example say your text file has the following format:

value01:value02:value03:value04
value11:value12:value13:value14

Where each new line is a new record and values are seperated by colons

What you would need to write is a php script that opens and reads that file line for line, exploding each line at the :, making an array of 4 values.

Then you use your pre-defined MySQL table that you built and give each field one of those four values, then go to the next line in the file.

Good call :)

phpman
Jul 31st, 2002, 04:23 PM
Originally posted by SystemShock
Thx.

I did all that, made the table manually and even entered a couple of records just to be sure.

Whenever I try to insert a txt file into a table it gives me an error saying that some tmp file wasn't found. I am quite sure I've entered information such as seperator etc properly.

Btw I'm using phpmyadmin(which comes with phptriad) for doing all this.

Please help.

Thx.
as far as I know phpMyAdmin will only except a certain format. what is the txt file? show us a couple of lines from it.