Results 1 to 2 of 2

Thread: Flat File 'Next Line' Issue

  1. #1
    Join Date
    Feb 2008
    Posts
    90
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default Flat File 'Next Line' Issue

    i wrote a script that sends a text message to a persons phone using the phones email address. I want to be able to monitor what is being sent across it. I have implemented a script that opens a flat file and write down the users name, the phone number they sent it to, and the message they sent. When someone else uses the form i want there information to be added to the next line of the flat file. However, i am unable to get this effect and every time i try, it just continues to write on the same line.
    Code:
    <?php
    print ("Thank you $name, your SMS Message has been sent.<p> Redirecting...");
    
    $fp = fopen("lastText.txt","a");
    if(!$fp) {
        echo 'Error: Cannot open file.  Dont worry your SMS was still sent.';
        exit;
    }
    $content = "$name,$phone,$message";
    
    fwrite($fp,$content."\n");
    
    fclose($fp);
    ?>

  2. #2
    Join Date
    Jul 2008
    Posts
    199
    Thanks
    6
    Thanked 58 Times in 57 Posts

    Default

    If you're viewing the file with a text editor like Windows' Notepad, the \n line breaks are not parsed correctly. Simply use a different text editor to view them.

Bookmarks

Posting Permissions

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