title: MySQL "Incorrect String Value" Error with utf8mb4 encoding
body: <p>I've been having a problem inserting some data into a varchar field of an InnoDB MySQL table with a PHP script.  Initially I thought the problem was caused by using utf8 character encoding because I did some research on the error I was getting, "Incorrect String Value" and found a couple of helpful posts here about switching my tables over to utf8mb4.</p>
  
  <p>So I switched it to 'utf8mb4'.  I did this in a couple of different places, in the server settings, the table settings, the database settings, and also in php via mysqli_set_charset.  I also tried changing the MySQL setting 'character-set-client-handshake' to see if that would make a difference, but I still got the error even after restarting the MySQL server.</p>
  
  <p>I decided that I would see if my PHP script was the problem so I opened up MySQL Workbench and entered the same query there.   Success!</p>
  
  <p>So, now I am really puzzled.  Why can I run the query in MySQL workbench but not via PHP?  Here is my code.</p>
  
  <p>In MySQL Workbench, this query works:</p>
  
  <pre><code>UPDATE books SET notes = 'Renâe Boivin, jeweller by Cailles, Franðcoise'  
  WHERE asin LIKE '0704370905'    
  </code></pre>
  
  <p>This is my PHP code for running that same query:</p>
  
  <pre><code>$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
  mysqli_set_charset($dbc, 'utf8mb4');
  $sql = "UPDATE books SET notes = 'Renâe Boivin, jeweller by Cailles,   
  Franðcoise' WHERE asin
  LIKE '0704370905'";
  </code></pre>
  
  <p>That code generates this error:</p>
  
  <p><code>"Error: Incorrect string value: '\xE2e Boi...' for column 'notes' at row 2"</code></p>
  
  <p>Any ideas?  Maybe I'm just overlooking something really simple.  I appreciate any suggestions.  Thank you!</p>