Results 1 to 6 of 6

Thread: PHP file writing help needed

  1. #1
    Far Superior To Meths EvilWeevil's Avatar
    Join Date
    Apr 2005
    Location
    London
    Posts
    936
    Thanks
    14
    Thanked
    8 times in 6 posts
    • EvilWeevil's system
      • Motherboard:
      • Asus P5W-DH Deluxe
      • CPU:
      • Intel Core 2 Duo E6600
      • Memory:
      • 2GB (2x1GB) Corsair XMS-2 PC2-6400
      • Storage:
      • 320GB Caviar, 320GB DiamondMax 10, 400GB Spinpoint, 1TB MyBook External
      • Graphics card(s):
      • Asus EAX1900XT
      • PSU:
      • OCZ GameXStream 700W
      • Case:
      • Lian-Li PC-G70B
      • Monitor(s):
      • Dell 2407WFP
      • Internet:
      • Homechoice/Tiscali 8 down/1 up

    PHP file writing help needed

    I'm writing a little php script to add text to a txt file, but need to add it to the beginning of the file without erasing it all. Any ideas? AFAIK fwrite doesn't do this...

    My DeviantArt | tomhendriks.co.uk | Need something (reasonable) hosted? PM me!

  2. #2
    Ah, Mrs. Peel! mike_w's Avatar
    Join Date
    Oct 2003
    Location
    Hertfordshire, England
    Posts
    3,326
    Thanks
    3
    Thanked
    9 times in 7 posts
    Stick the file in $variable, $variable = $sometextyouwantoadd . $variable, write the file?
    "Well, there was your Uncle Tiberius who died wrapped in cabbage leaves but we assumed that was a freak accident."

  3. #3
    Far Superior To Meths EvilWeevil's Avatar
    Join Date
    Apr 2005
    Location
    London
    Posts
    936
    Thanks
    14
    Thanked
    8 times in 6 posts
    • EvilWeevil's system
      • Motherboard:
      • Asus P5W-DH Deluxe
      • CPU:
      • Intel Core 2 Duo E6600
      • Memory:
      • 2GB (2x1GB) Corsair XMS-2 PC2-6400
      • Storage:
      • 320GB Caviar, 320GB DiamondMax 10, 400GB Spinpoint, 1TB MyBook External
      • Graphics card(s):
      • Asus EAX1900XT
      • PSU:
      • OCZ GameXStream 700W
      • Case:
      • Lian-Li PC-G70B
      • Monitor(s):
      • Dell 2407WFP
      • Internet:
      • Homechoice/Tiscali 8 down/1 up
    Thanks - should have thought of that myself

    My DeviantArt | tomhendriks.co.uk | Need something (reasonable) hosted? PM me!

  4. #4
    awm
    awm is offline
    Senior Member
    Join Date
    Apr 2006
    Location
    US
    Posts
    920
    Thanks
    4
    Thanked
    7 times in 7 posts
    the function fopen (http://us2.php.net/manual/en/function.fopen.php) takes a parameter for where to start reading and writing.

  5. #5
    Far Superior To Meths EvilWeevil's Avatar
    Join Date
    Apr 2005
    Location
    London
    Posts
    936
    Thanks
    14
    Thanked
    8 times in 6 posts
    • EvilWeevil's system
      • Motherboard:
      • Asus P5W-DH Deluxe
      • CPU:
      • Intel Core 2 Duo E6600
      • Memory:
      • 2GB (2x1GB) Corsair XMS-2 PC2-6400
      • Storage:
      • 320GB Caviar, 320GB DiamondMax 10, 400GB Spinpoint, 1TB MyBook External
      • Graphics card(s):
      • Asus EAX1900XT
      • PSU:
      • OCZ GameXStream 700W
      • Case:
      • Lian-Li PC-G70B
      • Monitor(s):
      • Dell 2407WFP
      • Internet:
      • Homechoice/Tiscali 8 down/1 up
    Quote Originally Posted by awm
    the function fopen (http://us2.php.net/manual/en/function.fopen.php) takes a parameter for where to start reading and writing.
    However opening at the beginning overwrites the file - only opening 'a' allows you to add and that's at the end.

    My DeviantArt | tomhendriks.co.uk | Need something (reasonable) hosted? PM me!

  6. #6
    awm
    awm is offline
    Senior Member
    Join Date
    Apr 2006
    Location
    US
    Posts
    920
    Thanks
    4
    Thanked
    7 times in 7 posts
    I guess there's no clever way to do it, I'd take Mike suggestion then, it should work great.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need help on my maxtor harddrives
    By arthurleung in forum PC Hardware and Components
    Replies: 10
    Last Post: 12-06-2007, 09:40 PM
  2. help needed - cant burn any dvds anymore
    By rolph in forum Help! Quick Relief From Tech Headaches
    Replies: 0
    Last Post: 03-06-2006, 02:45 AM
  3. Nero vision express saying:'Burn process failed'
    By johnnr892 in forum Help! Quick Relief From Tech Headaches
    Replies: 15
    Last Post: 11-12-2005, 11:43 PM
  4. Dodgy DVD-r's ?
    By starside in forum Help! Quick Relief From Tech Headaches
    Replies: 12
    Last Post: 27-03-2005, 06:11 PM
  5. Writing to a file. (PHP)
    By Nasimov in forum Software
    Replies: 3
    Last Post: 04-05-2004, 08:20 PM

Posting Permissions

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