Results 1 to 7 of 7

Thread: Writing to a file?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    190

    Writing to a file?

    I know how to write to a file, but I want to know if its possible to write to a certain part of the file? The code I use to write text to a file:

    PHP Code:
    $support="Name: " $name "\nMessage: " $msg "\nEmail: " $email "\nDate: " $Date;

    $fp=fopen("support.php""a+");            
    fwrite($fp$support); 
    fclose($fp); 
    How would I make that write after and before some code? So the code looks like this:-

    Code:
    <HTML><TITLE>Support</TITLE>
    <br/><br/>
    Name: my name
    Message: my message
    Email: myemail
    Date: 06 August 2007
    </HTML>

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Writing to a file?

    you want to append the text then:

    PHP Code:
    fopen($filename'a'
    My usual boring signature: Something

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    190

    Re: Writing to a file?

    I already do that, but I want it to write to a certain part of the file (before </html>)

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Writing to a file?

    try reading the contents of the folder to a string, then ad the info to the begining of the string. And add it to the file.

    PHP Code:
    $fp foppen("file""a+");
    $content fread($fp);
    $string "Add this to begining";
    $content $string $content;
    $write fwrite($fp$content);
    fclose($fp); 
    Last edited by dclamp; Aug 5th, 2007 at 11:02 PM.
    My usual boring signature: Something

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    190

    Re: Writing to a file?

    If I did that it'll repeat the code in the file.

  6. #6
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Writing to a file?

    show me what you want to add to the beginning of the file
    My usual boring signature: Something

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    190

    Re: Writing to a file?

    Code:
    <HTML><TITLE>Support</TITLE>
    <br/><br/>
    Then the message and after the message:-

    Code:
    </HTML>

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