Hello everyone,I had placed this same question in another thread but sadly it was never answered.

This is a response to one of 'OnlyHumans' reply in the thread this question was posted in: Since you have posted I have been learning learning and learning about what you wrote. Many of the terms you used such as the eof term I had never heard about haha. What you wrote really helped me understand what I had in my head, the CMS system. However, i now have a related question to what I have added your script. Instead of posting the variable 'message' to the eof, I placed the content of 'message' at the beginning of the file with fseek. My problem though, is that I cannot get a break to occur between posts. I could make a break happen with the eof, so is there something different that you have to do with fseek to use html for things like breaks and new lines? ( Are they the same thing? )

if( isset($_POST['message']) && ($_POST['message'] != null) ) { // this should actually be filtered as well $message = $_POST['message']; //Opens the file $fp = fopen("repost.php","r+"); //Moves the cursor back to beginning of the file. The '0' represents the character location. fseek($fp,0); //Writes the content of variable "message" to the pre-specified file. fwrite($fp, "<br>$message<br />");

//Opens the file $fp = fopen("repost.php","r+"); //Moves the cursor back to beginning of the file. The '0' represents the character location. fseek($fp,0); //Writes the content of variable "message" to the pre-specified file. fwrite($fp, "<br>$message<br />");

The problem is you fseek to the beginning of the file and write to it. Well, what happens is you end up overwriting whatever was at the beginning of the file before. IE: this is like having a file with the contents AAAAAAAAAA and then opening it, fseek'ing to 0 and writing BBBBBB, the file will then contain BBBBBBAAAA.

As i said, this is more of an implementation flaw then anything though.

You should never make such assumptions on unprocessed text unless it happens to be highly domain specific and _alot_ is known about it, and thats usually fairly advanced.

So what you need to do is read and parse the file into a domain specific object that you can safely interact with. Once the file is parsed into a data structure you can actually work with you can go about walking it and displaying it however you want. Persisting the data it to disk should be another straightforward level of abstraction.

"If art interprets our dreams, the computer executes them in the guise of programs!" - SICP

“If at first, the idea is not absurd, then there is no hope for it” - Albert Einstein