I am in the process of building a comment system for my website, however I have come across a problem.
I can get the comments displaying correctly when they are submitted to the database, but when I try to echo them out in the textarea they do not display properly. I will try and explain it below...
Say if the user typed in the textarea the following...
Hello, I do like this...
...My name is bob.
But if the user get's an error when submitting the form, it will not display like that when it is echoed out again, it will be something like this...
Hello, I do like this...\n\n\n\r\n\n\n\r...My Name is bob.
It would display all in one block. So how would I be able to echo it out again just as the user typed it in the first place?
I have already tried using nl2br() and also stripslashes().
Thanks in advance.
Form Textareas...
Moderator: General Moderators
Re: Form Textareas...
When you are displaying it after an error, is it being displayed inside the textarea again, or as HTML?
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Re: Form Textareas...
Check the nl2br() function.
-
lostprophetpunk
- Forum Newbie
- Posts: 21
- Joined: Sat May 31, 2008 3:49 am
Re: Form Textareas...
If you were to read my original post you would see that I have already tried that function already...Bill H wrote:Check the nl2br() function.
It is being echoed into the textarea.SpecialK wrote:When you are displaying it after an error, is it being displayed inside the textarea again, or as HTML?
-
mattpointblank
- Forum Contributor
- Posts: 304
- Joined: Tue Dec 23, 2008 6:29 am
Re: Form Textareas...
Are you using any functions on the inputted text? Specifically, mysql_real_escape_string() or htmlentities()?
textarea poda koiyanga
<textarea width="50' height="89">
-
lostprophetpunk
- Forum Newbie
- Posts: 21
- Joined: Sat May 31, 2008 3:49 am
Re: textarea poda koiyanga
What are you doing?nagarajan wrote:<textarea width="50' height="89">
Yes, I am using mysql_real_escape_string() on the inputted text.mattpointblank wrote:Are you using any functions on the inputted text? Specifically, mysql_real_escape_string() or htmlentities()?
-
mattpointblank
- Forum Contributor
- Posts: 304
- Joined: Tue Dec 23, 2008 6:29 am
Re: Form Textareas...
There's your problem - it escapes the linebreaks so they won't display as linebreaks again in the textarea. Try using stripslashes() on it before outputting it. If you're allowing HTML into the textbox it's going to be even more complicated...