DjKillerMemeStar
DjKillerMemeStar

Reputation: 425

TinyMCE write to database and retrieve from database

I have a TinyMCE editor that sends it's data to my database. The code that makes it work (so SQL doesn't throw a syntax error):

$artikel = htmlentities($_POST["artikel"]);

But now i'm trying to put it back into a TinyMCE editor to change the text. This kinda works but the formating isn't coppied over (see image). The code for this is:

echo'<script>$( window ).load(function(){tinymce.get("artikel").setContent("' . $row["Tekst"] . '");});</script>';

enter image description here

How can i make it so the text gets put in the editor with the formatting applied?

Upvotes: 0

Views: 937

Answers (1)

Michał Ochociński
Michał Ochociński

Reputation: 455

You haven't got formatted text because HTML tags was escaped. For example

should be transformed to &lt;p&gt;. Please check what exactly are you getting in $row["Tekst"].

To reverse this behavior you can use

htmlspecialchars_decode()

Remember, this is unsafe for security!

Upvotes: 2

Related Questions