Results 1 to 8 of 8

Thread: Database as a txt file

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2002
    Posts
    37

    Database as a txt file

    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/botf...net_listing.gz

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    You can't use MySQL on a text file. It has to be a MySQL database. Unless I'm confused here.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2002
    Posts
    37
    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.

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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.

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2002
    Posts
    37
    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.

  6. #6
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    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.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  7. #7
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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
    My evil laugh has a squeak in it.

    kristopherwilson.com

  8. #8
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width