Search code examples
phpsqloraclewysiwyghtml-entities

PHP htmlentities Double Encoding


I'm trying to save the contents of a WYSIWYG input into an Oracle database. Here's what I'm using:

$data = htmlentities($_POST['data'], ENT_QUOTES, "UTF-8");

My expectation is that when I'm going to put John's as the value for the input, it will be saved on the database as John's, but instead it is being saved as John'.

To me it looks like a double HTML entity encoding issue.

Can you help me fix this?


Solution

  • Browsing through the documentation, I noticed that the last parameter is a boolean for double encoding.

    $data = htmlentities($_POST['data'], ENT_QUOTES, "UTF-8", false);
    

    did the trick.