Page 1 of 1

Mysql to html Php parsing

Posted: Sun Sep 23, 2007 12:17 pm
by Brandensmith1
Hi, I recently made a news update page for my website and noticed whenever I use html in the news update it prints it out on the news page instead of doing what the html is meant to do (ie. <img src="banana"> echo's that txt instead of the image of a banana) anyone know a site with an example script of a php parser that can recognize the html tags or know where I might find a tutorial for one? If not html does anyone know how to do the BBCode like on these forums, that also would be cool. Sorry if I sound like a complete newbie, but in all honesty I am.

Thanks! Branden.

Posted: Sun Sep 23, 2007 12:30 pm
by feyd
I would guess that your code uses htmlspecialchars() or its sibling htmlentities().. that's a good thing. You don't want people to be able to post HTML willy-nilly.

There are various tools for keeping posted HTML safe. HTML Purifier is one of the more robust. If you want down and dirty there's strip_tags() and similar functionality.

As far as bbcode goes, there are many options.. some of which have been posted about previously -- search for them if interested. There's also Wikiwiki style syntax too. I've posted a basic parser previously: viewtopic.php?t=70453