Page 1 of 1

Echo Command on Text with html code

Posted: Mon Oct 31, 2005 3:03 pm
by murph2481
I want to print out information from a mysql database that has values such like:

<tag>blahblahblah</tag>

From a text field. But I want that raw string to show on the page. When I do an echo command for that column i get a blank, but if i view the source i see the tag values there. How can I print out html code from a mysql database as text on an HTML page?

Thanks,
Dan

Posted: Mon Oct 31, 2005 3:06 pm
by hawleyjr
Please show your code.

Posted: Mon Oct 31, 2005 3:07 pm
by Chris Corbyn
Pass the data through the PHP function:

htmlspecialchars() or htmlentities()

Thank You

Posted: Mon Oct 31, 2005 3:10 pm
by murph2481
Perfect!

htmlspecialchars() does the job!

Thank You,
Dan

Posted: Mon Oct 31, 2005 4:15 pm
by feyd
...and to answer your (yet realized) follow-up question: nl2br()