• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

How to preserve input formatting of text which is saved to db ?

How can you preserve input formatting  of text which is submitted through an input box which spans several lines. By formatting, I mean break lines, tab , blank line etc... especially, if this input is saved to a database and then later retrived for viewing. Too many times, you submit a text which is nicely formatted, but when you view it again, it has lost all of its formatting and has become a single paragraph text which is incomprehensible.
Thanks all.
0
attila1
Asked:
attila1
1 Solution
 
aryuminCommented:
s/&/&/g;
s/"/"/g;
s/\t/ &nbp;  /g;
s/</&lt;/g;
s/>/&gt;/g;
s/\n/<br>/g;
0
 
anant99Commented:
$whatever =~ s/\n/<br>/g;
$whatever =~ s/</&lt;/g;
$whatever =~ s/>/&rt;/g;
$whatever =~ s/"/&quot;/g;

$whatever is the name of variable which contains the contents of the input box.

Anant
0
 
MoondancerCommented:
Please update/finalize this.
Moondancer
Community Support Moderator @ Experts Exchange
0
 
Computer101Commented:
Comment from expert accepted as answer.

Thank you
Computer101
E-E Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now