1

我正在使用 PHP 来填充我的 DataTables 选择框。

如果我使用 DataTables 页面添加新条目(单击“添加”按钮),我对重音符号(特殊字符)没有任何问题,但如果我使用 phpMyAdmin 页面(sql 命令)添加新条目,则字段不显示通过包含重音符号的 phpMyAdmin 页面添加的内容(json_encode 为此字段返回 null)。

这是行错误:

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


我尝试使用 utf8_encode,尝试将 mysqli 字符集声明为 UTF8,我的 MySQL 字符集默认为 UTF8。

为什么通过DataTable页面添加的条目显示正常,而phpMyAdmin添加的条目却没有?

这是我的 HTML/PHP 代码:

<?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>
4

0 回答 0