Page 1 of 1

HTML Formatting

Posted: Tue Oct 14, 2008 12:32 pm
by Apryle
I have stored text in a mysql db with html formatting. When I look at the stored data in 'events_body' in PHPmyAdmin, it looks like:

<p>This is some <strong>sample text</strong>. My website is <a href="http://www.allyourssolutions.com/">All Yours Solutions</a></p>

I am trying to retrieve and echo 'events_body' on http://estesparkeventplanners.com/events.php using the following code:

Code: Select all

<?  
$result = mysql_query("SELECT * FROM events")
or die(mysql_error());  
 
// store the record of the "events" table into $row
$row = mysql_fetch_array( $result );
 
// Print out the contents of the entry 
echo htmlspecialchars($row['events_body']); 
?>
If you go to http://estesparkeventplanners.com/events.php, you'll see my problem is that it's outputting as if it's straight-up text, without the HTML formatting. I need it to interpret the HTML tags as HTML.

Any help is greatly appreciated.

Re: HTML Formatting

Posted: Tue Oct 14, 2008 12:44 pm
by califdon
Try it without using the html_special_characters() function. That converts things like < to <, which is not what you want to do.

Re: HTML Formatting

Posted: Tue Oct 14, 2008 12:48 pm
by Apryle
Thanks. That was simple and solved my problem. Is there a way to mark this solved?