Re: [PHP] text insertion

2011-08-10 Thread Ashley Sheridan


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
prevent SQL injection;

But when I call the data with php from the database the format it was
inserted is not preserved. Is there a way to make sure when a user
adds new paragraphs or indentation it will be preserved?

Thank you,

Chris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

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 is actually being 
output.

Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] text insertion

2011-08-10 Thread Chris Stinemetz
 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 is actually being 
 output.

Thanks Ashley

Source is showing indentation and new paragaraphs just as I inserted
the text. How can I get HTML output to show same format?


Chris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] text insertion

2011-08-10 Thread Shaun Farrell
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 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 with php from the database the format it was
 inserted is not preserved. Is there a way to make sure when a user
 adds new paragraphs or indentation it will be preserved?
 
 Thank you,
 
 Chris
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 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 is actually being 
 output.
 
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 -- 
 Sent from my Android phone with K-9 Mail. Please excuse my brevity.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] text insertion

2011-08-10 Thread Daniel P. Brown
: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 
 columns in a textarea won't work either. Look at the html source code to see 
 what is actually being output.

 Thanks Ashley

 Source is showing indentation and new paragaraphs just as I inserted
 the text. How can I get HTML output to show same format?

Use HTML 'pre' tags:

pre?php echo $your_content; ?/pre

-- 
/Daniel P. Brown
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] text insertion

2011-08-10 Thread Chris Stinemetz

    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',
strtotime($posts_row['store_date'])) . '/strong/td
/tr
tr class=visit
td class=post-contentBroad Band test results:/strong ' .
$posts_row['store_tptest'] . 'br/br/pre'
.$posts_row['store_comments'] . '/pre/td
/tr';

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] text insertion

2011-08-10 Thread hdedeyan
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 
php-general@lists.php.net

 
 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',
 strtotime($posts_row['store_date'])) . '/strong/td
 /tr
 tr class=visit
 td class=post-contentBroad Band test results:/strong 
 ' .
 $posts_row['store_tptest'] . 'br/br/pre'
 .$posts_row['store_comments'] . '/pre/td
 /tr';
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


Re: [PHP] text insertion

2011-08-10 Thread Chris Stinemetz
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 daniel.br...@parasane.net
 Cc: Ashley Sheridan a...@ashleysheridan.co.uk, PHP General 
php-general@lists.php.net

  
  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',
  strtotime($posts_row['store_date'])) . '/strong/td
  /tr
  tr class=visit
  td class=post-contentBroad Band test results:/strong
  ' .
  $posts_row['store_tptest'] . 'br/br/pre'
  .$posts_row['store_comments'] . '/pre/td
  /tr';
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 


Re: [PHP] text insertion

2011-08-10 Thread 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 Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] text insertion

2011-08-10 Thread Tim Streater
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 indeed what you want.

But can you put a pre/pre inside a table cell? (I don't know that you 
can't, but it seems an odd thing to do).

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: [PHP] text insertion

2011-08-10 Thread Ashley Sheridan


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 describing is accurate and correct, then
 pre is indeed what you want.

But can you put a pre/pre inside a table cell? (I don't know that
you can't, but it seems an odd thing to do).

--
Cheers  --  Tim

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

First thing that jumps out at me is that the pre tags are apparently ignored. 
This suggests one of those ridiculous reset.css files being used, which uses 
css to style every Danny element the same. If its set to override the 
whitespace setting in a pre tag then that could cause the issue you are 
seeing, as I've never known pre tags to fail like that.

Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP] text insertion

2011-08-10 Thread Tim Streater
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 this purpose.

--
Cheers  --  Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php