vessio
February 20, 2010, 6:49pm
1
Hello,
I am having some trouble with line breaks passing through a textarea to the database. I understand a few of the methods when reading a bit, though there seems to be a few different methods to accomplish a clean display from a textarea.
I would appreciate any assistance.
Thanks in advance!
I assume you mean to convert it so that it’s viewable in HTML?
The simplest approach would be to use nl2br ().
The comments on that page should also help you.
vessio
February 20, 2010, 7:16pm
3
Thanks Jake, I am giving this a go right now.
vessio
February 20, 2010, 7:40pm
4
Well it seems that I am getting a similar variation returning “rnrn” on new lines in the submitted data.
Perhaps my glitch is obvious to you, this is the original code snip I am working with.
<?php
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$text = stripslashes($row['text']);
if(!$row['isadmin'] == 1)
{
echo "<div class=\\"fileRow\\">".$text."";
}
else
{
echo "<div class=\\"fileRow admin\\">".$text."";
}
}
if(isset($_POST['comment']))
{
echo "<div class=\\"fileRow admin\\">".stripslashes($comment)."";
}
?>
Yes, you should remove the stripslashes().
vessio
February 20, 2010, 7:47pm
6
Did the trick, thanks a lot Jake!