Q:

How to fix a JSON_ERROR_UTF8

I keep getting a JSON_ERROR_UTF8 error.  After looking around for a while, I haven't found a solution that has worked.  This PHP code works for returning other columns in my table, resolution is just different resolutions stored as a VARCHAR in the format 1024x768, some being N/A and some being blank. 
<? php
require "conn.php";

//$mysql_qry = $_POST["query"];
$mysql_qry = "SELECT resolution FROM settings ORDER BY id ASC;";
//creating an array for storing the data 
$settings = array(); 

//creating an statment with the query
 $stmt = $conn->prepare($mysql_qry);

//executing that statment
$stmt->execute();

//binding results for that statment 
$stmt->bind_result($resolution);

//looping through all the records
while($stmt->fetch()){

 //pushing fetched data in an array 
 $temp = [
 'resolution'=>$resolution,
 ];

 //pushing the array inside the settings array 
 array_push($settings, $temp);
}
echo json_encode($settings)
? >

If I replace the last line echo json_encode($settings) with var_dump($settings)
The returned values are as expected: 
array(134) { [0]=> array(1) { ["resolution"]=> string(8) "1024x768" } [1]=> array(1) { ["resolution"]=> string(8) "1024x768" } [2]=> array(1) { ["resolution"]=> string(8) "1024x768" } [3]=> array(1) { ["resolution"]=> string(8) "1024x768" } [4]=> array(1) { ["resolution"]=> string(8) "1024x768" } [5]=> array(1) { ["resolution"]=> string(8) "1024x768" } [6]=> array(1) { ["resolution"]=> string(8) "1280x800" } [7]=> array(1) { ["resolution"]=> string(8) "1280x960" } [8]=> array(1) { ["resolution"]=> string(8) "1024x768" } [9]=> array(1) { ["resolution"]=> string(9) "1680x1050" } [10]=> array(1) { ["resolution"]=> string(8) "1024x768" } [11]=> array(1) { ["resolution"]=> string(8) "1024x768" } [12]=> array(1) { ["resolution"]=> string(8) "1024x768" } [13]=> array(1) { ["resolution"]=> string(8) "1024x768" } [14]=> array(1) { ["resolution"]=> string(8) "1024x768" } [15]=> array(1) { ["resolution"]=> string(8) "1024x768" } [16]=> array(1) { ["resolution"]=> string(8) "1280x800" } [17]=> array(1) { ["resolution"]=> string(9) "1280x1024" } [18]=> array(1) { ["resolution"]=> string(8) "1024x768" } [19]=> array(1) { ["resolution"]=> string(8) "1024x768" } [20]=> array(1) { ["resolution"]=> string(3) "N/A" } [21]=> array(1) { ["resolution"]=> string(7) "800x600" } [22]=> array(1) { ["resolution"]=> string(8) "1024x768" } [23]=> array(1) { ["resolution"]=> string(8) "1280x800" } [24]=> array(1) { ["resolution"]=> string(8) "1024x768" } [25]=> array(1) { ["resolution"]=> string(8) "1024x768" } [26]=> array(1) { ["resolution"]=> string(8) "1280x720" } [27]=> array(1) { ["resolution"]=> string(9) "1440x1080" } [28]=> array(1) { ["resolution"]=> string(8) "1280x960" } [29]=> array(1) { ["resolution"]=> string(8) "1024x768" } [30]=> array(1) { ["resolution"]=> string(8) "1280x960" } [31]=> array(1) { ["resolution"]=> string(8) "1280x960" } [32]=> array(1) { ["resolution"]=> string(8) "1024x768" } [33]=> array(1) { ["resolution"]=> string(8) "1280x960" } [34]=> array(1) { ["resolution"]=> string(8) "1280x800" } [35]=> array(1) { ["resolution"]=> string(8) "1280x720" } [36]=> array(1) { ["resolution"]=> string(8) "1600x900" } [37]=> array(1) { ["resolution"]=> string(9) "1680x1050" } [38]=> array(1) { ["resolution"]=> string(8) "1600x900" } [39]=> array(1) { ["resolution"]=> string(8) "1024x768" } [40]=> array(1) { ["resolution"]=> string(3) "N/A" } [41]=> array(1) { ["resolution"]=> string(8) "1280x720" } [42]=> array(1) { ["resolution"]=> string(9) "1680x1050" } [43]=> array(1) { ["resolution"]=> string(8) "1024x768" } [44]=> array(1) { ["resolution"]=> string(8) "1024x768" } [45]=> array(1) { ["resolution"]=> string(8) "1024x768" } [46]=> array(1) { ["resolution"]=> string(9) "1920x1080" } [47]=> array(1) { ["resolution"]=> string(9) "1920x1080" } [48]=> array(1) { ["resolution"]=> string(9) "1280x1024" } [49]=> array(1) { ["resolution"]=> string(8) "1024x768" } [50]=> array(1) { ["resolution"]=> string(8) "1280x960" } [51]=> array(1) { ["resolution"]=> string(8) "1024x768" } [52]=> array(1) { ["resolution"]=> string(8) "1280x960" } [53]=> array(1) { ["resolution"]=> string(8) "1600x900" } [54]=> array(1) { ["resolution"]=> string(8) "1280x960" } [55]=> array(1) { ["resolution"]=> string(8) "1024x768" } [56]=> array(1) { ["resolution"]=> string(8) "1280x768" } [57]=> array(1) { ["resolution"]=> string(8) "1024x768" } [58]=> array(1) { ["resolution"]=> string(8) "1024x768" } [59]=> array(1) { ["resolution"]=> string(8) "1024x768" } [60]=> array(1) { ["resolution"]=> string(8) "1280x960" } [61]=> array(1) { ["resolution"]=> string(8) "1024x768" } [62]=> array(1) { ["resolution"]=> string(8) "1024x768" } [63]=> array(1) { ["resolution"]=> string(9) "1280x1024" } [64]=> array(1) { ["resolution"]=> string(8) "1024x768" } [65]=> array(1) { ["resolution"]=> string(8) "1024x768" } [66]=> array(1) { ["resolution"]=> string(8) "1024x768" } [67]=> array(1) { ["resolution"]=> string(8) "1024x768" } [68]=> array(1) { ["resolution"]=> string(8) "1280x960" } [69]=> array(1) { ["resolution"]=> string(9) "1920x1080" } [70]=> array(1) { ["resolution"]=> string(8) "1024x768" } [71]=> array(1) { ["resolution"]=> string(8) "1024x768" } [72]=> array(1) { ["resolution"]=> string(8) "1024x768" } [73]=> array(1) { ["resolution"]=> string(8) "1280x960" } [74]=> array(1) { ["resolution"]=> string(9) "1280x1024" } [75]=> array(1) { ["resolution"]=> string(8) "1024x768" } [76]=> array(1) { ["resolution"]=> string(8) "1024x768" } [77]=> array(1) { ["resolution"]=> string(8) "1024x768" } [78]=> array(1) { ["resolution"]=> string(7) "800x600" } [79]=> array(1) { ["resolution"]=> string(8) "1280x960" } [80]=> array(1) { ["resolution"]=> string(8) "1024x768" } [81]=> array(1) { ["resolution"]=> string(9) "1920x1080" } [82]=> array(1) { ["resolution"]=> string(9) "1920x1080" } [83]=> array(1) { ["resolution"]=> string(9) "1920x1080" } [84]=> array(1) { ["resolution"]=> string(9) "1920x1080" } [85]=> array(1) { ["resolution"]=> string(8) "1024x768" } [86]=> array(1) { ["resolution"]=> string(9) "1920x1080" } [87]=> array(1) { ["resolution"]=> string(8) "1280x720" } [88]=> array(1) { ["resolution"]=> string(9) "1920x1080" } [89]=> array(1) { ["resolution"]=> string(8) "1024x768" } [90]=> array(1) { ["resolution"]=> string(8) "1024x768" } [91]=> array(1) { ["resolution"]=> string(8) "1280x960" } [92]=> array(1) { ["resolution"]=> string(8) "1024�768" } [93]=> array(1) { ["resolution"]=> string(8) "1024x768" } [94]=> array(1) { ["resolution"]=> string(8) "1024x768" } [95]=> array(1) { ["resolution"]=> string(8) "1024x768" } [96]=> array(1) { ["resolution"]=> string(8) "1280x768" } [97]=> array(1) { ["resolution"]=> string(9) "1280x1024" } [98]=> array(1) { ["resolution"]=> string(0) "" } [99]=> array(1) { ["resolution"]=> string(8) "1024x768" } [100]=> array(1) { ["resolution"]=> string(8) "1024x768" } [101]=> array(1) { ["resolution"]=> string(8) "1024x768" } [102]=> array(1) { ["resolution"]=> string(3) "N/A" } [103]=> array(1) { ["resolution"]=> string(3) "N/A" } [104]=> array(1) { ["resolution"]=> string(9) "1440x1080" } [105]=> array(1) { ["resolution"]=> string(8) "1024x768" } [106]=> array(1) { ["resolution"]=> string(9) "1280x1024" } [107]=> array(1) { ["resolution"]=> string(8) "1280x960" } [108]=> array(1) { ["resolution"]=> string(8) "1280x960" } [109]=> array(1) { ["resolution"]=> string(8) "1024x768" } [110]=> array(1) { ["resolution"]=> string(8) "1024x768" } [111]=> array(1) { ["resolution"]=> string(8) "1024x768" } [112]=> array(1) { ["resolution"]=> string(8) "1024x768" } [113]=> array(1) { ["resolution"]=> string(9) "1280x1024" } [114]=> array(1) { ["resolution"]=> string(8) "1024x768" } [115]=> array(1) { ["resolution"]=> string(8) "1280x960" } [116]=> array(1) { ["resolution"]=> string(8) "1280x960" } [117]=> array(1) { ["resolution"]=> string(8) "1280x960" } [118]=> array(1) { ["resolution"]=> string(8) "1024x768" } [119]=> array(1) { ["resolution"]=> string(8) "1024x768" } [120]=> array(1) { ["resolution"]=> string(8) "1024x768" } [121]=> array(1) { ["resolution"]=> string(7) "800x600" } [122]=> array(1) { ["resolution"]=> string(3) "N/A" } [123]=> array(1) { ["resolution"]=> string(8) "1024x768" } [124]=> array(1) { ["resolution"]=> string(8) "1024x768" } [125]=> array(1) { ["resolution"]=> string(8) "1024x768" } [126]=> array(1) { ["resolution"]=> string(8) "1024x768" } [127]=> array(1) { ["resolution"]=> string(8) "1024x768" } [128]=> array(1) { ["resolution"]=> string(8) "1024x768" } [129]=> array(1) { ["resolution"]=> string(9) "2560x1440" } [130]=> array(1) { ["resolution"]=> string(8) "1280x960" } [131]=> array(1) { ["resolution"]=> string(8) "1024x768" } [132]=> array(1) { ["resolution"]=> string(8) "1280x960" } [133]=> array(1) { ["resolution"]=> string(9) "1280x1024" } }

A:

You can remove them:
 $string = preg_replace('/[^[:print:]]/', '', $string);

Which removes any non-printable characters (but it will remove some stuff), it's a lot harder to replace them, a lot of edge case stuff. 
But as you are getting these from the DB you can try to set the charset on the DB connection:
mysqli_set_charset( $link ,'utf8' );
//Or if you are using the OOP mysqli
$conn->set_charset('utf8');
//Or PDO
$conn = new PDO("mysql:host=$host;dbname=$db;charset=utf8", $user, $pass);

Which may fix the issue too.   The best bet is to clean the data up when inserting it into the DB.