Jump to content

Rendering HTML from a MYSQL table


bentobenji

Recommended Posts

PHP Version 5.2.5 entropy release 6

php mysql library versions 5.0.45

mysql vx 5.1.32 on server localhost via unix socket

 

There has got to be a simple answer, so I would appreciate if someone is nice enough to help out this newbie.

 

Basically, I have medium sized data with html tags in it. I want to read the data into a php variable with the html tags in tact to then display it correctly in the browser. I can get my data and print/echo it, but it converts the html tags into ascii characters rather than the appropriate html rendering.

 

I'm able to grab the data on my little zend framework site using the foreach loop and a conditional and storing in it a var like '$content2'.  This works beautifully so no need to give code for that.

 

Then when I go to display one of the content variables like so:

 

<?php print $content2; ?>

 

It renders all of the HTML in the data as ascii.  E.g., the bit of data from mysql '<h2>Hot off the press!</h2>' is rendered in the source code as '<h2>Hot off the press!</h2>',  In other words, it renders literally '<h2>Hot off the press!</h2>' in the web browser.

 

I've done this before with XML by putting <![CDATA[ ]] around the data node, and it works beautifully. However, this doesn't work with mysql. I've tried different text, varchar, blob data types to the same effect. It seems that the browser would see the tags and just read them as html, but I guess I'm missing something.

 

I really prefer to keep the html tags for certain purposes. I know how to place html tags around bits of data and all that, but I want the text to come preformatted.

 

There's got to be a way!  Can anyone help me??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.