HTML Formatting

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Apryle
Forum Newbie
Posts: 7
Joined: Wed Jul 18, 2007 12:54 pm

HTML Formatting

Post 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.
Last edited by Apryle on Tue Oct 14, 2008 12:49 pm, edited 1 time in total.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: HTML Formatting

Post by califdon »

Try it without using the html_special_characters() function. That converts things like < to <, which is not what you want to do.
Apryle
Forum Newbie
Posts: 7
Joined: Wed Jul 18, 2007 12:54 pm

Re: HTML Formatting

Post by Apryle »

Thanks. That was simple and solved my problem. Is there a way to mark this solved?
Post Reply