Echo Command on Text with html code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
murph2481
Forum Newbie
Posts: 20
Joined: Mon Jun 27, 2005 1:48 pm

Echo Command on Text with html code

Post 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
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Please show your code.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Pass the data through the PHP function:

htmlspecialchars() or htmlentities()
murph2481
Forum Newbie
Posts: 20
Joined: Mon Jun 27, 2005 1:48 pm

Thank You

Post by murph2481 »

Perfect!

htmlspecialchars() does the job!

Thank You,
Dan
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

...and to answer your (yet realized) follow-up question: nl2br()
Post Reply