Reputation: 26565
This is my code:
$blogid = mysql_real_escape_string($_GET['id']);
if((isset($_POST['comment']))&&(!(trim($_POST['comment'])==FALSE))&&(isset($_SESSION['userid']))){
$comment = mysql_real_escape_string($_POST['comment']);
$querycomment = "INSERT INTO `comment` (`userid`, `blogid`, `body`) VALUES ( '".$_SESSION['userid']."', '".$blogid."', '".$comment."');";
$rowchat = mysql_query($querymess,$db_con) or die("Failed: " . mysql_error() );
}
<form method="post" action="blog.php?id=<?php echo $blogid; ?>" >
<textarea name="comment" ></textarea>
<input type="submit" value="send" name="submit" />
</form>
When a User comment this:
This
is
my
world
Then in the comments list appears this:
This is my world
Why doesn't line break works ?
Upvotes: 0
Views: 75
Reputation: 39550
Because line breaks are saved as \n
.
You can use the PHP function nl2br($string)
before echo'ing the string.
<?php
$string = "This\nis\nmy\nworld";
echo nl2br($string);
?>
Upvotes: 5