2

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.

2
  • if its valid html, on a valid html page then there should be no issue, post it so we can take a look Commented Dec 5, 2011 at 6:22
  • Should work. Can you please post some code? Commented Dec 5, 2011 at 6:23

1 Answer 1

7

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

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

Sign up to request clarification or add additional context in comments.

3 Comments

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.
oh i know, just saying is all, based on the question its as valid an answer as well any :-)
Have you got an example of how i can use html_entity_decode with the echo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.