For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > March 2006 > blank lines problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author blank lines problem
Bruintje Beer

2006-03-25, 3:57 am

Hello,

I have a strange problem using php and textarea input. When i have an
textarea in a form like

line 1 etc etc
blank line
line 3 etc etc
line 4 etc etc
blank line
blank line
line 7

Later I put the textarea in a mysql table. Reading back and display in an
textarea. I see that the text is one line discarding the blank lines. How
can I preserve the blank lines when storing in database and reading back in
php.

thanks

Johan


rlee0001

2006-03-25, 7:57 am

Line feeds should be automatically preserved. What are you doing to the
input prior to the INSERT call? What are you doing to output after the
SELECT call? What does the HTML source of the textarea look like when
it is read from the database?

-Robert

Bruintje Beer

2006-03-25, 6:57 pm


"rlee0001" <robeddielee@hotmail.com> schreef in bericht
news:1143282965.440587.39440@i40g2000cwc.googlegroups.com...
> Line feeds should be automatically preserved. What are you doing to the
> input prior to the INSERT call? What are you doing to output after the
> SELECT call? What does the HTML source of the textarea look like when
> it is read from the database?
>
> -Robert
>


$query = "select * from tbl_profile where id = $id";'
$result = mysql_query($query);
$row = mysql_fetch_assoc($result)
$profile_oms = $row['profile_oms'];
<textarea name="profiel_oms" rows="10" class="textfield" id="profiel_oms">
<?php
print "$profile_oms";
?>
</textarea>

Johan


rlee0001

2006-03-25, 6:57 pm

Hmm,

There is nothing there to remove line feeds from the data. Are you sure
the data was stored with line feeds intact? When you view the resulting
HTML source is the content of the textarea all on one line or does it
just render that way?

If you really are getting a single line of text from that query, the
data was stored without line feeds and you should check to INSERT (or
UPDATE) procedures. It might also be possible that a CSS style is being
applied to the textarea so that it ignores line feeds and renders its
contents all on one line. Try sending $profile_oms to the contents of a
PRE tag as well.

Also, make sure you apply a htmlspecialchars to any output from a data
source that is sent to an HTML document.

-Robert

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com