...">

Save html text in database

I want to save html-formatted text to the database, but when I do this, it does not save html characters like </ "> 'and others. Here's how I read an article from the database for editing:

<p class="Title">і і:</p>
    <textarea name="EN" cols="90" rows="20" value="<?php echo htmlentities($articleArr['EN'], ENT_QUOTES, "UTF-8"); ?>" ></textarea>

after that it generates the following html code:

<p class="Title">і і:</p>
    <textarea name="EN" cols="90" rows="20" value="&lt;p class=&#039;Title&#039;&gt;  &lt;/p&gt;" ></textarea>

So, I expect this text to appear in my text box, in the html code of this page it is, but not in the text area.

In the database, I save it as:

<p class="Title"> Hello </p>

So how can I do this:

  • Read from the HTML-FormattedText database.
  • Show in textarea element.
  • Edit and save it in the database.

Please help me, how can I save such texts correctly, Thanx!

+5
source share
2

htmlspecialchars() , , , htmlspecialchars_decode(). .

+30

All Articles