MySQL无法将汉字返回变量

时间:2014-08-09 18:39:21

标签: php mysql pdo phpmyadmin

我无法在MySQL之外获得汉字字符,kanjis通常会从phpmyadmin中显示出来,但是当它被拖出变量时它就会变成???,它们已成为???,已经尝试添加

          <meta charset=utf-8 /> 

但仍然无法运作。这是我的代码的一部分

    <?php
        include_once('class/word.php');
        include_once('conn/connection.php');
        $conn = get_koneksi();
        $sql = "SELECT * FROM tb WHERE id=? LIMIT 1";
                $stm= $conn -> prepare($sql);
        $stm -> bindParam(1, $_REQUEST['id']);
        $stm-> execute();
        if ($stm-> rowCount() > 0) {
            $row = $stm-> fetch();
          #this result nothing
            echo "<script>alert(".$row['kanji'].");</script>";
           $item = new word($row['id'],$row['word'],$row['kanji'],$row['length']);
          #this result undefined -> $item->getKanji() is blank in alert
            echo "<script>alert(".$item->getKanji().");</script>";
          #this result ???? character instead kanjis
          echo "<div style='width:700px;position:absolute;'><h1>".$item->getKanji()."</h1></div>";
        }else echo "No Data Found !";
    ?>

如何在PDO使用中解决这个问题?

0 个答案:

没有答案