title: MySQL insert String error - UTF-8?
body: <p>I am inserting into a mysql database. I get the following error when trying to do the insert</p>
  
  <pre><code>Incorrect string value: '\xF0\x9F\x87\xB7\xF0\x9F...' for column 'field_4' at row 1
  </code></pre>
  
  <p>I thought I had figured out this error by simply changing the column encoding the to utf8mb4 and had tested but recently this error appeared again. I am using php to parse the string and run the following function before inserting...</p>
  
  <pre><code>function strip_emoji($subject) {
      if (is_array($subject)) {
          // Recursive strip for multidimensional array
          foreach ($subject as &amp;$value) $value = $this-&gt;strip_emoji($value);
          return $subject;
      } else {
          // Match Emoticons
          $regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
          $clean_text = preg_replace($regexEmoticons, '', $subject);
  
          // Match Miscellaneous Symbols and Pictographs
          $regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
          $clean_text = preg_replace($regexSymbols, '', $clean_text);
  
          // Match Transport And Map Symbols
          $regexTransport = '/[\x{1F680}-\x{1F6FF}]/u';
          $clean_text = preg_replace($regexTransport, '', $clean_text);
          return 
  }
  </code></pre>
  
  <p>There are several similar questions to this but I still have these errors. Any further advice on how to prevent this error? I realize that it is an emoji unicode character / sprite but not sure how to deal with it.</p>