MyBB Community Forums

Full Version: No new line on my website, please help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In my website, the news table doesn't have a new line after i type a message.

When typing and you want to make a new line or empty space you press the button 'Enter', but somehow this doesn't work on my website

It is not a forum. I have attached images to show my problem
Try adding <br /> or <br>
I can't add that everytime i post since it is php based and i escape html with htmlspecialchars
The point is that there should have been a line break, but there isn't...and it is very strange
(2010-07-14, 06:48 PM)dikidera Wrote: [ -> ]I can't add that everytime i post since it is php based and i escape html with htmlspecialchars
The point is that there should have been a line break, but there isn't...and it is very strange

Write a custom htmlspecialchars function that replaces "\n" with "<br />"

function special($string, $endls = '<br />') {
$string = htmlspecialchars($string, ENT_QUOTES);
if (substr_count($string, "\n")) {
$string = str_replace("\n", $endls, $string);
if (substr_count($string, "\r")) {
$string = str_replace("\r", '', $string);
}
}
else if (substr_count($string, "\r")) {
$string = str_replace("\r", $endls, $string);
}
return $string;
}
Or use white-space: wrap for the display CSS, might work.
The question is why did this happen? I have seen the template i use(modified tho) in a website and they got no problems...i checked the source and there is no <br /> where a new line begins in that website.

I checked my html(from browser) and i see the new lines, but in the website they are not appearing
White-space property seems to have done it's job, but why did this happen? I really want to know