Developing a blog site, having issues displaying text while in edit mode
Blog body variable is being saved into mysql as:
$body = mysql_real_escape_string($_POST['body']);
Extracting it from DB like:
$body = nl2br($row['body']);
and using echo $body
to show it.
I want users to be able to embed video, and use html tags in their blogs, the issue I'm having is when the user enters "edit" mode to ch开发者_运维知识库ange the blog, you can see all of the html linkbreak tags. Is there a way to show all html tags except for the linebreak tag?
There are a couple of things that are going on with your code sample. First, you should be using mysqli_real_escape_string
instead of mysql_real_escape_string
, here are a few reasons why.
Second, you don't want to use nl2br
until you're displaying the text.
精彩评论