#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    france
    Posts
    0
    Rep Power
    0
    Sorry for my poor english:
    I'm new in php programming, but i don't understand the way to put a file.txt (witch is in a server's directory) into a table field (longtext for exemple).
    I know fopen, fread, I can view the file but don't know how to ask php to write this file in the table.
    Thanks for help

    ------------------
    newbie
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4476
    I'm assuming you know how to connect to MySQL and are familiar with SQL statements...

    The way to do it would be open the file, read in the line or lines that you want to insert into one row of mysql data, and assign it to a variable. then do an insert in mysql. maybe something like this, assuming each piece of text you want to insert is one one line in the file.

    $fd = fopen("/tmp/inputfile.txt", "r");
    while ($buffer = fgets($fd, 4096)) {
    $result = mysql_query("insert into you_table (longtext) values ('$buffer')");
    }
    fclose($fd);

    Hope that helps.

    ---JH
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    france
    Posts
    0
    Rep Power
    0
    Thanks John, for your help!
    I'm trying this tomorrow. It's too late this night.

Similar Threads

  1. Replies: 3
    Last Post: February 11th, 2004, 08:30 AM
  2. mysql data lost
    By imola in forum MySQL Help
    Replies: 1
    Last Post: February 10th, 2004, 07:39 AM
  3. Replies: 1
    Last Post: February 5th, 2004, 06:17 AM
  4. data manipulation in mysql
    By dbosz in forum MySQL Help
    Replies: 0
    Last Post: February 1st, 2004, 08:34 PM
  5. Replies: 0
    Last Post: January 30th, 2004, 08:46 PM

IMN logo majestic logo threadwatch logo seochat tools logo