Help ECHO HTML from database

I have a column called section in my database, and I stored Some Text

When it outputs it displays on my site - Some Text.

My code is as follows <?php print $sectiondescription; ?>

How could I make that force HTML. That field is set to VARCHAR at 8000.

Regards,
Josh

What do you mean by “force html”? That the code is displayed as HTML:

<a href="12345">Some Link</a>

Rather than the parsed HTML:

Some Link

Ops your right just was in a hurry this morning.

So in my code I have <?php print $sectiondescription; ?> which display all the text.

However when I store Some Text into the field it will only show the Some Text, and will not link the word.

Hope that helps :slight_smile:

Best Regards,
Josh

So what is being stored in the database?

This (the link HTML):

[php]Some Text[/php]

Or (the link text):

[php]Some Text[/php]

<a href="some-url.com">Some Text</a>

Is being stored in the database.

And when you output that you want it to be displayed as it is in the database?

In that case you can use htmlspecialchars:

[php]print htmlspecialchars($sectiondescription, ENT_QUOTES);[/php]

Will give it a shot when I get home :smiley:

Thank u

Sponsor our Newsletter | Privacy Policy | Terms of Service