PHP警告:json_encode():无效的UTF-8序列

I'm using PHP to populate my DataTables select boxes.

If I add a new entry using the DataTables page (clicking in the 'Add' button), I have no problem with the accents (special characters), but if I do add new entries using the phpMyAdmin page (sql command), the fields that were added via the phpMyAdmin page that contains accents are not displayed(json_encode returns null for this fields).

Here's the line error:

aDataInitial = '<?php  echo json_encode($stack); ?>';'


I've tried to use utf8_encode, tried to declare the mysqli charset as UTF8, my MySQL charset is UTF8 by default.

Why does the entries that are added via the DataTable page are displayed fine while the entries added by phpMyAdmin are not?

Here's my HTML/PHP code:

<?php   
    $connection = ($GLOBALS["___mysqli_ston"] = mysqli_connect('localhost',  'mbrconsu_un394x',  'y1cz9,rd+hf6')) or die(((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
    ((bool)mysqli_query( $connection, "USE mbrconsu_mmx")) or die(((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));

    $aFieldType = array ('tema', 'vinculo', 'empresa', 'subcontratada', 'gerencia', 'areasolicitante', 'cc');
    $stack=array();

    foreach ($aFieldType as $type)
    {
        $sql="SELECT {$type} FROM treinamentos ORDER BY {$type} ASC";
        $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql);

        while($row = mysqli_fetch_array($result))
        {
            $stack[$type][] = array($row[$type],$row[$type]);
        }
    }
?>
        <script type="text/javascript">
            aDataInitial = '<?php  echo json_encode($stack); ?>';
        </script>