Darren Griffin Darren Griffin - 1 year ago 91
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>

I am using TinyMCE to format the code.

Here is how I echo it

$conContent = $row['content'];

Then, when I go to the page, it displays the output like this...

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download