List:General Discussion« Previous MessageNext Message »
From:Roger Baklund Date:September 11 2005 9:49pm
Subject:Re: HTML in MySQL?
View as plain text  
Vladimir B. Tsarkov wrote:
> After the execution of the script:
> 
> <?php
> $string = "\n\n\n\n 1";
> echo addslashes($string);
> ?>
> 
> we will get:
> 
> 1
> 
> and no empty lines.
> 
> If you want to output the same data, that was written using a textarea field 
> of a form, you should use the "<br>" tag.

In one word: kiss. Converting the data before inserting it in the 
database, and converting it back after reading from the database, is 
more work and more error-prone, compared to not doing this conversion. 
You can easily do the conversion when you output the data, _if_ the 
output format is html, _and_ you actually want "hard" linefeeds in your 
html output. Many web pages have a variable width... there is a reason 
for why whitespace usually is not significant in html.

The problem you describe above is not related to mysql, and you could 
probably solve it another way. You should take a look at the html <pre> 
element.

-- 
Roger

Thread
HTML in MySQL?clint lenard9 Sep
  • Re: HTML in MySQL?Jasper Bryant-Greene9 Sep
    • Re: HTML in MySQL?clint lenard9 Sep
      • Re: HTML in MySQL?Jasper Bryant-Greene9 Sep
        • Re: HTML in MySQL?clint lenard9 Sep
  • Re: HTML in MySQL?douglass_davis12 Sep
    • Re: HTML in MySQL?clint lenard12 Sep
      • Re: HTML in MySQL?clint lenard12 Sep
        • Re: HTML in MySQL?clint lenard12 Sep
          • Re: HTML in MySQL?Hassan Schroeder12 Sep
RE: HTML in MySQL?SST - Adelaide)9 Sep
Re: HTML in MySQL?Unknown Sender9 Sep
Re: HTML in MySQL?Unknown Sender9 Sep
RE: HTML in MySQL?Alan Williamson9 Sep
  • Re: HTML in MySQL?Unknown Sender9 Sep
    • Re: HTML in MySQL?gerald_clark9 Sep
    • Re: HTML in MySQL?Filipe Tomita9 Sep
  • Re: HTML in MySQL?Unknown Sender9 Sep
RE: HTML in MySQL?John Trammell9 Sep
Re: HTML in MySQL?Unknown Sender11 Sep
  • Re: HTML in MySQL?Roger Baklund11 Sep
Re: HTML in MySQL?Unknown Sender11 Sep
RE: HTML in MySQL?John Trammell11 Sep
  • Re: HTML in MySQL?Jasper Bryant-Greene12 Sep
    • Re: HTML in MySQL?Jasper Bryant-Greene12 Sep
      • Re: HTML in MySQL?clint lenard12 Sep