I have a form with one textarea for comments.
The problem is when there are line breaks (by pressing [enter]).
When I build the INSERT query for MySQL, the source code is semething like this:
INSERT INTO [table] (comments) VALUES ('This is my comment
with holy breaks')
Although It works, when this data is shown on the page, the source code is this:
<td>This is my comment
with holy breaks</td>
The point is that I need to display this content using overlib (javascript library) and It doesn't like these breaks, and it doesn't work.
The string should be like this: This is my comment<br />with holy breaks.
I've tried using PHP's function nl2br(), but I get the same string with boths elements: page break and <br />:
"This is my comment<br />
with holy breaks."
And that is even worst!
I'm also using smarty template, and it has a internal function nl2br too, but I get the same result.
What on earth is the problem?!
Thanks!
retrieving content from textarea
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
str_replace() newlines with nothing or <br /> depending on if you remove the nl2br() call or not.
It worked out by using str_replace("\r\n", " ", $txt);feyd wrote:str_replace() newlines with nothing or <br /> depending on if you remove the nl2br() call or not.
Thanks a lot!
Diego.-