I am encountering an issue where I need to retrieve formatted text from a database and display it in my TinyMCE editor.
The content stored in the database looks like this:
<p style="text-align: justify;"><strong>Zdravím</strong></p>
Here is the script I am using:
<script type="text/javascript">
// Initialization TinyMCE (JS)
tinyMCE.init({ ... });
function loadText(text) {
var editor = window.parent.tinyMCE.activeEditor;
editor.setContent(text);
}
</script>
// PHP
$q = mysql_query("SELECT * FROM article WHERE id = ".$_GET['id']."");
while ($z = mysql_fetch_array($q)) {
$text = html_special_chars($z['content']);
}
When I try to load static content, it works fine:
<body onload = "loadText('hello');">
But when I try to load dynamic content like this:
<body onload = "loadText('<? echo $text; ?> ');">
It doesn't work!
I suspect the issue might be related to quotes and apostrophes. Any other ideas or suggestions?