Reply to Re: preserving line breaks in mysql

Your name:

Reply:


Posted by meltedown on 07/26/05 01:46

Hilarion wrote:
>> I tried mysql_escape_string as you suggested, with partial success
>>
>> test line 1
>> test line 2
>> is changed to
>> test line 1\r\ntest line 2 value2
>>
>> And it goes into the database like that.
>> When I pull it out of the data base it is:
>> test line 1
>> test line 2
>>
>> Which is fine, but when I use that as the default for a textbox in a
>> form, it shows up as:
>> test line 1test line 2
>

OK, my mistake. What actually went into the textbox didn't have a line
break, it was removed by my function that tidys up the html source code.
Thats the first time I've ever needed "\n" in a web page except to
tidy up the source code. Thanks for the help.
>
> That's strange. When I try this HTML code:
> <textarea>test line 1
> test line 2</textarea>
> Then I get the text in two lines.
> Are you sure your PHP generates similar code?
> (Other thing is that you should use "htmlentities" before
> echoing the text to prevent values like "</textarea>some
> text" screw your form.)
>
>
>> How do I get the new line to show up in the textbox ?
>
>
> As I showed above: by using newline in the text.
>
>
>> If I use nl2br(),
>> it shows up as
>> test line 1<br />test line 2
>> in the text box, instead of
>> test line 1
>> test line 2
>
>
> That's quite normal - HTML inside TEXTBOX is not interpreted
> as HTML (till nearest "</textarea>" tag).
>
>
> Hilarion

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация