title: HTML tags saved to database as HTML entities
body: <p>I am using this code to update values in a database:</p>
  
  <pre><code>function text_save( $page_name, $page_title, $page_text ) {
  
      $servername = "127.0.0.1";
      $username = "abcd";
      $password = "password";
      $dbname = "thedatabase";
  
      // Create connection
      $conn = new mysqli( $servername, $username, $password, $dbname );
  
      // Check connection
      if ( $conn-&gt;connect_error ) {
          die( "Connection failed: " . $conn-&gt;connect_error );
      }
  
      $page_content = $page_text;
  
      $sql = "UPDATE text SET page_title=?, page_text=? WHERE text_name=?";
  
      // prepare and bind
      $stmt = $conn-&gt;prepare( $sql );
  
      // check whether the prepare() succeeded
      if ( $stmt === false ) {    
          trigger_error( $this-&gt;mysqli-&gt;error, E_USER_ERROR );
      }
  
      $stmt-&gt;bind_param( 'sss', $page_title, $page_content, $page_name );
  
      $stmt-&gt;execute();
  
      print '&lt;p&gt;Text saved&lt;/p&gt;';
  
      $stmt-&gt;close();
      $conn-&gt;close();
  }
  </code></pre>
  
  <p>The variable <code>$page_text</code> is set from a tinymce text area on a form submission and is HTML content.</p>
  
  <p>If I var_dump the value of <code>$page_text</code>, it comes out as:
  <code>string(23) "&lt;p&gt;test&lt;/p&gt;"</code></p>
  
  <p>When the <code>$page_content</code> data is saved to the database, it is saved as:</p>
  
  <pre><code>&amp;lt;p&amp;gt;test&amp;lt;/p&amp;gt;
  </code></pre>
  
  <p>However, if I manually set the value of <code>$page_content</code> to
      <code>&lt;p&gt;test&lt;/p&gt;,</code></p>
  
  <p>e.g. <code>$page_content = "&lt;p&gt;test&lt;/p&gt;";</code> instead of 
  <code>$page_content = $page_text;</code></p>
  
  <p>it is saved to the database as:</p>
  
  <pre><code>&lt;p&gt;test&lt;/p&gt;
  </code></pre>
  
  <p>I need the HTML to be saved to the database without being converted to HTML entities i.e. as <code>&lt;p&gt;test&lt;/p&gt;</code> not <code>&amp;lt;p&amp;gt;test&amp;lt;/p&amp;gt;</code>?</p>
  
  <p><strong>This is what I have tried so far:</strong></p>
  
  <p>Setting the page to utf8 - <code>&lt;meta charset="utf-8" /&gt;</code>,</p>
  
  <p>setting the form to utf8 - <code>accept-charset="UTF-8"</code>,</p>
  
  <p>setting the connection to utf8 - <code>mysqli_set_charset($conn,"utf8");</code></p>
  
  <p>setting the tinymce init with - <code>entity_encoding : "raw"</code></p>
  
  <p>What am I doing wrong here, and why does the HTML string save correctly when I manually set the variable rather than using the form variable value (which seems to be identical)?</p>
  
  <p>Thanks very much!</p>