howardmoore Posted May 19, 2009 Share Posted May 19, 2009 Hi, I am a very new to HTML, so please go easy on the explanations. I have tried searching the forum but unfortunately I didn't understanding much of what I read. I have a PHP script that writes to a MySQL database. One particular row ('description') uses HTML, as I use fckeditor to create the content. fckeditor and the form I wrote posts the content to the database just fine using: $description=htmlspecialchars($description,ENT_QUOTES); When I browse the row using phpMyadmin the htmlspecialchars has worked perfectly. However, the problem I have is when I am trying to show the contents of 'description' on a webpage. I use the following: <?php $sql = "SELECT * FROM `jmnpevents` WHERE startDate between '".date("Y-m-d")."' AND '".date("Y-m-d",mktime(0, 0, 0, date("m"), date("d")+$daysAhead, date("Y")))."' ORDER BY startDate ASC"; $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql); while ($row = mysql_fetch_assoc($sql_result)) { if ($row["description"]<>'') { echo '<table class="calendar_list"><tr><td class="calendar_list_date">'; echo date("F j, Y",strtotime($row["startDate"])).' - <strong>'; echo nl2br(stripslashes(utf8_decode($row["name"]))).'</strong></td></tr>'; echo '<tr><td class="calendar_list_description">'; echo stripslashes(utf8_decode($row["description"])).'</td></tr></table><br /><br />'; }; }; ?> However, this only shows the content as HTML tags, rather then rendering it properly as HTML. Does anyone know what I can do to solve this problem. I presume that it is something to do with the decoding, but for the life of me the searches I have done have not shed any light. Thanks in advance. Neil Quote Link to comment Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 htmlspecialchars_decode() Quote Link to comment Share on other sites More sharing options...
howardmoore Posted May 19, 2009 Author Share Posted May 19, 2009 htmlspecialchars_decode() Thanks - I did see this in some of the searches I did, but I cannot work out where this will fit into my code. I have tried replacing utf8_decode with htmlspecialchars_decode, but this just returns no results at all. Thanks, Neil Quote Link to comment Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 Can you post here an example of what is echoed in place of $row["description"] when retrieving data? Quote Link to comment Share on other sites More sharing options...
howardmoore Posted May 19, 2009 Author Share Posted May 19, 2009 When using utf8_decode I get: <p><span style="color: #0000ff">Coloured Blue</span></p> <p><span style="color: #00ff00">Coloured Green</span></p> When using htmlspecialchars_decode() I get nothing at all. The page just stops at the point where it is meant to display, meaning that the rest of the page template failes to display too. Quote Link to comment Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 When using utf8_decode I get: <p><span style="color: #0000ff">Coloured Blue</span></p> <p><span style="color: #00ff00">Coloured Green</span></p> When using htmlspecialchars_decode() I get nothing at all. The page just stops at the point where it is meant to display, meaning that the rest of the page template failes to display too. Is an error printed when using htmlspecialchars_decode()? Turn error_reporting on: error_reporting(E_ALL); //put this at the top of your script Quote Link to comment Share on other sites More sharing options...
howardmoore Posted May 19, 2009 Author Share Posted May 19, 2009 Thanks. I get the following: Fatal error: Call to undefined function: htmlspecialchars_decode() in ... Quote Link to comment Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 Thanks. I get the following: Fatal error: Call to undefined function: htmlspecialchars_decode() in ... Err... Try using html_entity_decode(). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.