Hello, i'm really new to PHP, so i'll try to explain my problem the best i can..
Im creating a news board in flash, its a pretty typical setup, the user has his/hers admin page, this is where they enter a new post, flash submits the post to PHP and PHP writes the new post into a .txt file for the main flash page to pick up.
this is where the problem is, The txt file needs to retain news= at the very beginning of the .txt file after every post,
for example, the .txt file would read;
news= <p>12/12/07, this is a post about something<br /></p>
<p>13/12/07, and another<br /></p>
<p>14/12/07, and another<br /></p>
this is my current PHP code which adds the post, but doesn't write news= at the begining of the .txt file like i need it to.
<?php
$Submit = $_POST["Submit"];
$post = $_POST["new_news"];
$post = ereg_replace('[^A-Za-z 0-9,./?><";:\~!\'\"\/@#[](){}]', "", $post);
if ($Submit == "Yes") {
$filename = "../news.txt";
$fp = fopen( $filename,"r+");
$old_data = fread($fp, 80000);
fclose( $fp );
$date = (date ("(g:i A) l - d F Y"));
$input = "<p align=\"left\">$date<br>$post<br></p>";
$new = "$input$old_data";
$fp = fopen( $filename,"w");
if(!$fp) die("&error =Failed to write!");
fwrite($fp, $new, 800000);
fclose( $fp );
}
?>
Could someone PLLEEEAASSEEE help me with this, i've been stuck on it for 2 days!
if you need me to explain it further, then just ask...