Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Text Area Formatting

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I saw one of the post regarding textarea formatting. I need a clear idea of how to retain the format entered in the text area . The data entered goes to the database and i retrieve it from the database.
I don't know whether it goes with new line characters or not becoz
if i write
Hi,
This is your friend,
bye,
cs.
This gets me as Hi,This is your friend,bye,cs. all in one line
Anybody pls hlp.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
to come the new line u will press enter key right,
which wont store in the db, if u want it u have specify with the escape
seqence character
 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
shouldn't it be stored OK if you use a prepared statement?
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
No it should not be and you'll get the same format as you entered in to the textarea. may be you need to check how the value is stored in the database. just look at the data base field using the data field.
have a nice time
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I personally escape the whole text area with a function and store it into the database. When I retrieve the information it will display the way that I want it to. I also use someother function to find links, custom tags, etc.
Eric
 
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup go with Eric's idea. That is what I do too.
To check the newline character, I check for "\n", single quotes, double quotes, etc and replace them with escape sequence. Instead of directly storing in the DB, let it go through some function first.
This is the replace function I generally use :

hth
MB
 
We must storm this mad man's lab and destroy his villanous bomb! Are you with me tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic