Solved

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

Posted on 2001-06-21
4
156 Views
Last Modified: 2013-12-25
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
Comment
Question by:attila1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 5

Accepted Solution

by:
aryumin earned 100 total points
ID: 6217452
s/&/&/g;
s/"/"/g;
s/\t/ &nbp;  /g;
s/</&lt;/g;
s/>/&gt;/g;
s/\n/<br>/g;
0
 
LVL 1

Expert Comment

by:anant99
ID: 6223735
$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
 
LVL 1

Expert Comment

by:Moondancer
ID: 6699427
Please update/finalize this.
Moondancer
Community Support Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6903866
Comment from expert accepted as answer.

Thank you
Computer101
E-E Moderator
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question