Darren Griffin Darren Griffin - 6 months ago 23
HTML Question

PHP variable with HTML formatting

Here is my variable that I am actually getting from my MySQL Database:

<h1>This is a H1</h1>
<p>NOT BOLD</p>
<p>&nbsp;</p>
<p><strong>BOLD</strong></p>


I am using TinyMCE to format the code.

Here is how I echo it

<?php
// WHILE LOOP GETTING $ROW FROM MYSQL
$conContent = $row['content'];


Then, when I go to the page, it displays the output like this...
http://i.snag.gy/BbMqx.jpg

I want the variable to make the echo formatted. So like then it will have all the html formatting.

Answer

Can you check the HTML source of the output? Is the HTML still around? It looks like strip_tags() or HTMLPurifier removes your HTML. Otherwise you would either see the formatting applied or the tags in the output.

If you have HTML code in your database you don't have to do anything with it in PHP, but can directly print it.