How do I preserve text formatting when text is inserted into a database table?
For example: I am using a textarea to allow users to leave comments
into the database and I am using:
' . mysql_real_escape_string($_POST['store_comments']) . ', to
prevent SQL injection;
But when I call the data
Chris Stinemetz chrisstinem...@gmail.com wrote:
How do I preserve text formatting when text is inserted into a database
table?
For example: I am using a textarea to allow users to leave comments
into the database and I am using:
' . mysql_real_escape_string($_POST['store_comments']) . ', to
Are you sure its not preserved? When you output text in a browser, by default
its output as html, not plain text. Html ignores extraneous whitespace, and
doesn't use a monospaced font, so formatting text into columns in a textarea
won't work either. Look at the html source code to see what
You could try using markdown too.
Sent from my iPhone
On Aug 10, 2011, at 3:57 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
Chris Stinemetz chrisstinem...@gmail.com wrote:
How do I preserve text formatting when text is inserted into a database
table?
For example: I am using
:On Wed, Aug 10, 2011 at 16:02, Chris Stinemetz
chrisstinem...@gmail.com wrote:
Are you sure its not preserved? When you output text in a browser, by
default its output as html, not plain text. Html ignores extraneous
whitespace, and doesn't use a monospaced font, so formatting text into
Use HTML 'pre' tags:
pre?php echo $your_content; ?/pre
I just tried that and that puts all the text on a single line.
echo 'tr class=topic-post
td class=user-poststrong' . $posts_row['first_name'] . ' ' .
$posts_row['last_name'] . ' ' . date('m-d-Y h:iA',
how about
echo nl2br($your_content);
- Original Message -
From: Chris Stinemetz chrisstinem...@gmail.com
Date: Wednesday, August 10, 2011 5:09 pm
Subject: Re: [PHP] text insertion
To: Daniel P. Brown daniel.br...@parasane.net
Cc: Ashley Sheridan a...@ashleysheridan.co.uk, PHP General
No luck. Thanks.
On Aug 10, 2011 4:17 PM, hdede...@videotron.ca wrote:
how about
echo nl2br($your_content);
- Original Message -
From: Chris Stinemetz chrisstinem...@gmail.com
Date: Wednesday, August 10, 2011 5:09 pm
Subject: Re: [PHP] text insertion
To: Daniel P. Brown
On Wed, Aug 10, 2011 at 17:37, Chris Stinemetz chrisstinem...@gmail.com wrote:
No luck. Thanks.
Per list rules, please don't top-post.
If the situation you're describing is accurate and correct, then
pre is indeed what you want.
--
/Daniel P. Brown
Dedicated Servers, Cloud and Cloud
On 10 Aug 2011 at 22:39, Daniel P. Brown daniel.br...@parasane.net wrote:
On Wed, Aug 10, 2011 at 17:37, Chris Stinemetz chrisstinem...@gmail.com
wrote:
No luck. Thanks.
Per list rules, please don't top-post.
If the situation you're describing is accurate and correct, then
pre is
Tim Streater t...@clothears.org.uk wrote:
On 10 Aug 2011 at 22:39, Daniel P. Brown daniel.br...@parasane.net
wrote:
On Wed, Aug 10, 2011 at 17:37, Chris Stinemetz
chrisstinem...@gmail.com
wrote:
No luck. Thanks.
Per list rules, please don't top-post.
If the situation you're
On 10 Aug 2011 at 22:07, Chris Stinemetz chrisstinem...@gmail.com wrote:
Use HTML 'pre' tags:
pre?php echo $your_content; ?/pre
I just tried that and that puts all the text on a single line.
You could write the string into another textarea, which you could make readonly
for
12 matches
Mail list logo