I am using a function of php called rewind(points to a file that has been opened by fopen()) and I have the following code.
[code=php]
$newsfile = ‘shownews.php’;
$handle = @fopen($newsfile, ‘a+’) or die(‘I was unable to open ‘ . $newsfile);
rewind($handle);
That section of the code should work I think, it sets the news file,(this is for a news system btw? ), opens it using fopen using handle, and then the rewind is called. Now forgive me if I am wrong but rewind places the pointer at the begining of the file, so that if you were to write to the file, it would write it in at the begining? That is what I am wanting to do so that my news shows up at the top so people dont have to scroll down to see the latest news. Now this is my writing code.
[code=php]if((!empty($_POST[‘title’])) and (false === strpos($newslog, $_POST[‘title’])))
{
# Add the new news to the news file
fwrite($handle, “<b><h4><center>”.$title.”</center></b></h4><br>”);
fwrite($handle, “<b>Written by:</b> <i>”.$author.”</i><br>”);
fwrite($handle, $news.”<br>”);
fwrite($handle, “<hr>”);
# Update $newslog for use in output
$newslog .= “<b><h4><center>”.$title.”</center></b></h4><br>”;
$newslog .= “<b>Written by:</b> <i>”.$author.”</i><br>”;
$newslog .= “<br><br> “.$news.”<br>”;
$newslog .= “<hr>”;
}
I just dont see why the rewind isn’t working. Can anyone help me out?
Thanks,
[b]~[i]Travis