kimbarcelona
kimbarcelona

Reputation: 1136

HTML tags from Database not interpreted as HTML in browser

So I have a record in the database from a field named comments.

Comment from <a href='www.google.com'># 12345</a><b>Hello</b>

but upon displaying in the browser, it's not being interpreted as HTML but as a plain text and displaying as is.

I'm expecting:

Comment from # 12345Hello

Code so far:

$comment = $adb->query_result($result,$i,'comments');
$comment = wordwrap($comment, 150, " ", true);
$comment = htmlentities($comment, ENT_QUOTES);

I've tried to comment out htmlentities line but still displaying the same. Any idea how can I solve this?

Upvotes: 4

Views: 1167

Answers (1)

ElefantPhace
ElefantPhace

Reputation: 3814

Try using html_entity_decode()

$comment = html_entity_decode($comment);

You can also try using htmlspecialchars_decode

$comment = htmlspecialchars_decode($comment);

Upvotes: 4

Related Questions