Ok, I have a fairly basic script that just takes the contents of a text file on the server and dumps it into a text box so that the user can edit it. It has some JavaScript associated with it to facilitate the easy insertion of HTML formatting, kinda like the BBcode buttons on this forum.
Anyway, the issue is every time I update the file (take the value out of the textarea, save it to the file using fwrite(), and then pull the data back out of the file and plop it into the textarea) it doubles the number of line breaks.
For example:
I enter in:
hello
one space
So the first time the file is saved the number of spaces = 2
I hit the save button again and the number of spaces = 4
I hit the save button again and the number of spaces = 8
I have other textareas on the site that store data into a MySQL database and these don't exibit the same problem even though they use very similar code, the main difference is one reads the text into and out of a file and the other read the text into and out of a table in the database.
For some reason stripslashes() or trim(), even when used before the text is saved and before the text is put into the textarea don't do anything.
I even tried $content = str_replace("\n", "new line", $content); before the text is put into the textarea and when I put this into the text box:
I get this on the first save:
testing
new lineONE space
second save:
testing
new line
new linenew lineONE space
thrid save:
testing
new line
new linenew line
new line
new linenew linenew lineONE space
PLEASE explain! This is driving me crasy because it shouldn't be doing this.