Generating a new line in a text file

From: Date: Fri, 18 Jan 2002 04:46:23 +0000
Subject: Generating a new line in a text file
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-81023@lists.php.net to get a copy of this message
It should be fairly simple, but it's got me and everyone else I've asked utterly stumped, all I need to do is place the data from a form on a newline in a text file, I can get the data into the text file, but I can't seem to get it on a new line. Here's what I have at the moment: $quote = stripslashes($newquote); $quote = sprintf("$quote%s",'\n'); $quotage = fopen("quotes.txt","a"); fputs($quotage, $quote); fclose($quotage); echo"<p>New quote added to quotes.txt</p>"; echo $quote; The form is a standard form that posts back to it's own page, an if statement picks up a hidden form entry and shifts the data across to the above code, so far so good. But it's at this point that I become stuck. What do I need to do to get it to put the new quote onto a new line of the text file? The reason I need it this way is that the code that pulls the quotes back out again chooses them randomly by line. (it's a somewhat dodgy random number generator in essence, but it does the job) If all else fails, I could put the whole lot into a mysql database table and redo the code for the random quote generator, but using a database when a flat file will do seems like overkill to me. TIA Chris Janes

« previous php.general (#81023) next »