Results 1 to 8 of 8
Thread: textarea, mysql, php
-
05-28-2003, 05:15 PM #1Temporarily Suspended
- Join Date
- Jan 2003
- Posts
- 160
textarea, mysql, php
hey,
im working on a forum for my website, and for the signatures they:
enter it into a <textarea>
it goes through htmlspecialchars()
gets put in the database
then is selected and put below their post
thats all great, right?
no
i put in:
Livin` php style,
Xbox Live Gamertag: Hybrid Blade,
Nickname: DM PA,
Proud member of the Dark Minions Clan:
www.gamenationx.com/darkminions/
and below their post it reads:
Livin` php style., Xbox Live Gamertag: Hybrid Blade, Nickname: DM PA, Proud member of the Dark Minions Clan: www.gamenationx.com/darkminions/
i have no idea whats wrong or how to fix it...
any ideas?
EDIT: btw. same thing happens with their actual post....
-
05-28-2003, 06:08 PM #2Aspiring Evangelist
- Join Date
- Dec 2002
- Location
- Fort Worth
- Posts
- 434
You need to properly set the "wrap" attribute of the textarea tag. <textarea wrap='physical'> will retain the newlines entered by your users.
-
05-28-2003, 06:18 PM #3Web Hosting Master
- Join Date
- May 2002
- Location
- UK
- Posts
- 2,997
Except you should be aware that 'wrap' is not a valid attribute for textarea under the XHTML 1.0 transitional standard (or even under HTML 4.01)
-
05-28-2003, 06:25 PM #4Aspiring Evangelist
- Join Date
- Jan 2002
- Location
- Adelaide, Australia
- Posts
- 405
nl2br() is what you need
it converts /n/r (which is what's in the text area) to <br /> in html.
so nl2br($text); before it goes into the database
-
05-28-2003, 06:30 PM #5Aspiring Evangelist
- Join Date
- Dec 2002
- Location
- Fort Worth
- Posts
- 434
but will there even be newlines in the text if wrap='physical' is not used. and if wrap is not standard, what is the solution?
-
05-28-2003, 06:33 PM #6Aspiring Evangelist
- Join Date
- Jan 2002
- Location
- Adelaide, Australia
- Posts
- 405
you get the new line by hitting enter That's a hard break (/n/r).
Wrapping is for easy reading, as far as all things are concerned it's just a long string with no breaks at all.
Wrapping in textarea's can be done with CSS now
-
05-28-2003, 07:31 PM #7Temporarily Suspended
- Join Date
- Jan 2003
- Posts
- 160
Originally posted by platinum
nl2br() is what you need
it converts /n/r (which is what's in the text area) to <br /> in html.
so nl2br($text); before it goes into the database
awesome. thanks it worked
-
05-29-2003, 04:35 AM #8Web Hosting Master
- Join Date
- May 2002
- Location
- UK
- Posts
- 2,997
Originally posted by platinum
you get the new line by hitting enter That's a hard break (/n/r).
Very annoying when you are trying generate email or http headers as they terminate with a double CRLF but differently under the two OS's