I have a chunk of html code stored in a field in a mysql database. If i try and echo it out it just sits on the page as text. Is there a way to echo it out in a working fashion. ( Meaning the html displays what it is meant to display )

The code is stored in a varchar field and i used nl2br with special characters to insert it. The code display's as text but it is what it should be.

Again can i echo the code out in a working way?

EDIT - This is the code that is displayed on the page.

<img name="" src="http://www.mysite.com/assets/viewcart.png" width="114" height="48"alt="" />

and this is the code stored in the database.

&lt;img name=&quot;&quot; src=&quot;http://www.mysite.com/assets/viewcart.png&quot; width=&quot;114&quot; height=&quot;48&quot; alt=&quot;&quot; /&gt;

The Echo request i used to get the code out was a simple.

echo $row['htmlcode'];

Thanks for any help and examples.

link|improve this question
if its valid html, on a valid html page then there should be no issue, post it so we can take a look – Dagon Dec 5 '11 at 6:22
Should work. Can you please post some code? – Mawg Dec 5 '11 at 6:23
feedback

1 Answer

up vote 3 down vote accepted

You could try running your text through html_entity_decode() before echoing it.

as in echo html_entity_decode($row['htmlcode']);

link|improve this answer
only if you encoded it before putting it in to the db – Dagon Dec 5 '11 at 6:24
I'm stabbing in the dark here, as the OP said that he could see the HTML code (so either it was rendered as plaintext, or was encoded). I'm just guessing. – Blender Dec 5 '11 at 6:25
oh i know, just saying is all, based on the question its as valid an answer as well any :-) – Dagon Dec 5 '11 at 6:26
well you where right, now he's posted some code. – Dagon Dec 5 '11 at 6:28
Awwww, yea! Code always makes things clearer. – Blender Dec 5 '11 at 6:30
show 4 more comments
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.