Log in

View Full Version : Flat File 'Next Line' Issue



SChaput
10-23-2008, 08:15 PM
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.


<?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);
?>

techietim
10-23-2008, 08:34 PM
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.