title: php/mysql : How to insert a gzcompress-ed string into a text mysql field?
body: <p>I have been trying to compress and store a json encoded string into mysql, but I am getting "unexpected /" errors.</p>
  
  <p>I also tried to use addslashes like this:</p>
  
  <pre><code>addslashes(gzcompress(json_encode($mystring)));
  </code></pre>
  
  <p>And to display</p>
  
  <pre><code>json_decode(gzuncompress(stripslashes($mystring)));
  </code></pre>
  
  <p>But it fails on insert with the error I mentioned.</p>
  
  <p>I read somewhere a string with gzcompress should be stored as a blob, but I was hoping there is a way to store it in a mysql text field so I dont have to mess with the db.</p>
  
  <p>PS: Some asked for full error message here it is:</p>
  
  <blockquote>
    <p>Warning: Unexpected character in input: '\' (ASCII=92) state=1</p>
    
    <p>PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect string
    value: '\x9C\xED}\x8Br\xDB...' for column 'field_text_value' at
    row 1.</p>
  </blockquote>