set_charset("utf8"); if($mysql->connect_errno) { echo "db connection error : " . $mysql->connect_error; exit(); } //default sql query with limit of 50 records if(empty($sql)) { $sql = "SELECT * FROM movieView where rating='PG' ORDER BY title LIMIT 50"; } $results = $mysql->query($sql); if(!$results) { echo "SQL error: ". $mysql->error; exit(); } $json_array = array(); while($currentrow = $results->fetch_assoc()) { $json_array[] = $currentrow; } /* echo "
"; print_r($json_array); echo ""; */ // $json2 = json_encode(mb_convert_encoding($json_array['name'], 'UTF-8', 'UTF-8')); // create new $json object that has full php array data, but encoded as json $json2 = json_encode($json_array, JSON_UNESCAPED_UNICODE); // echo "json error: " . json_last_error_msg() . "