saved html in mysql db displays as plain text when retrieved

  •  09-06-2010, 12:50 PM

    saved html in mysql db displays as plain text when retrieved

    I've just installed CuteEditor on a PHP site that stores notes in a MySQL database table.
    I've created a test note using CuteEditor. The html is storing precidsely in the table field, but when I retrieve it for display the web page literally displays the html code.
     
    Here's the code generated by CuteEditor  stored in my MySQL db record in a field called "note":
     
    <div><h3>This is my first note.</h3></div><div>&nbsp;</div><div><span style=\"color: red;\">My list:</span></div><div>&nbsp;</div><ol><li>one</li><li>two</li><li>three</li></ol><div>&nbsp;</div><div><img alt=\"\" src=\"/mysite/uploads/WashingtonCaYubaRiver.jpg\" width=\"450\" height=\"600\" />&nbsp;</div>
    <div>&nbsp;</div>
    <div><br />
    &nbsp;</div>
     
    The calling webpage displays that html code, not the expected output. I've cut and pasted the code into my html wyswyg editor and it displays perfectly.
     
    Here the context of the code in the webpage:
     
    $note = forDisplay( fromStorage( $row[2] ) );
    echo "<tr><td valign=\"top\" align=\"right\"><p><strong>Note:</strong></p></td><td align=\"left\">".$note."</td></tr>";
     
    ($row[2] is the stored field location in a query of the table holding the note. It's a "text" field in the table.
    I simple assign it to $note and try to display it within the surrounding html on the webpage, just as I've always done with other retrieved field data, but it just displays the actual html code.
     
    Here's the unexpected output:

    Note:

    <div><h3>This is my first note.</h3></div><div>&nbsp;</div><div><span style="color: red;">My list:</span></div><div>&nbsp;</div><ol><li>one</li><li>two</li><li>three</li></ol><div>&nbsp;</div><div><img alt="" src="http://cutesoft.net/mysite/uploads/WashingtonCaYubaRiver.jpg" width="450" height="600" />&nbsp;</div>
    <div>&nbsp;</div>
    <div><br />
    &nbsp;</div>
     
    I know this has to be something quite simple. Ideas?
     
     
View Complete Thread