title: JSON fails when retrieving a record has special characters
body: <p>I'm getting the error 'Unexpected end of JSON input' when using JSON to retrieve data from a MySQL db<br />
  The following code snippet calls GetProfileTest.php which executes a select statement and returns a record. The record contains the field value 'Athlète'.  If delete è from the field the codes runs without an error. The db is uses utf8_unicode_ci collation.</p>
  <p>The weird thing is the code works fine on another website with identical tables.</p>
  <p>Can anybody provide an insight has to what causes the error.  Eliminating the French characters is not an option.</p>
  <pre><code>    $.ajax({
      method: 'GET',
      url: '/wp-content/PHP/GetProfileTest.php',
      data :{&quot;CFF&quot;:CFF,&quot;LANG&quot;:LANG},
      &quot;timeout&quot;: 5000
  })  
  .fail(function (jqXHR, textStatus, errorThrown) {
      // Request failed. Show error message to user.
      alert('Data get failed: '+errorThrown);
  })
  .done(function(data, textStatus, jqXHR ) {
      var result= data;
      if ($.type(result)==&quot;string&quot;) {
          alert(&quot;No profile found &quot; + CFF); 
      };
  </code></pre>
  <p>Here is GetProfileTest.php</p>
  <pre><code>&lt;?php 
  
  // Revieve ID and query db to get profile
  
  // get connection data)
  require('Connection.php');
  
  /* Create connection */
  $conn =  mysqli_connect($host,$username, $password, $dbname);
  
  // Check connection
  if (!$conn){
    echo 'Connection error: '. mysqli_connect_error();
    }
   
   //  SQL query to get profile for the ID provided
   $CFF  = $_GET['CFF'];
   $LANG = $_GET['LANG'];
  
   if ($LANG == 'EN') {
      $sql = &quot;SELECT CFF_Num,VeteranName,Role_En FROM VeteranProfileView WHERE CFF_Num='&quot;.$CFF.&quot;'&quot;;
   }  else {
      $sql = &quot;SELECT CFF_Num,VeteranName,Role_Fr FROM VeteranProfileView WHERE CFF_Num='&quot;.$CFF.&quot;'&quot;;
   }
     $sql = &quot;SELECT CFF_Num,VeteranName,Role_Fr FROM VeteranProfileView WHERE CFF_Num='&quot;.$CFF.&quot;'&quot;;
   
   // Run Query and get result
   if (!$result = mysqli_query($conn,$sql)) {
      echo 'Query failed: '. mysqli_error($conn);
   }
  
   /* If there are results from query push to result array */
   $result_array = array();
   if ($result-&gt;num_rows &gt; 0) {
      while ($row = $result-&gt;fetch_assoc()) {
         array_push($result_array, $row);
      }   
      /* send a JSON encoded array to client */
      header('Content-type: application/json');
      echo json_encode($result_array);
   } else {
      echo ('No profile found');
   } 
  
  
   mysqli_free_result($result);
   mysqli_close($conn);
  </code></pre>