[請益] 輸入的中文_輸出均為問號

看板PHP作者 (go)時間13年前 (2012/03/06 20:55), 編輯推噓3(307)
留言10則, 5人參與, 最新討論串1/1
製作類似行事曆的網頁 在前端網頁上 輸入中文,重新按鈕顯示剛剛輸入的內容,凡中文的部分, 都以"?"顯示每個中文字 到後台的資料庫中 新增中文的資料 才可在網頁端 看到正常的中文輸出 (localhost測試正常) 有誰知道問題在哪嗎? 感謝! code: <?php class writeNote { var $userName = "user"; //帳號 var $password = "12345"; //密碼 var $hostName = "mysql14.000webhost.com"; //主機(Server)名稱 //取得之前的事情內容 function getNote($noteDate){ //建立資料連結 $mylink = mysql_connect($this-> hostName, $this-> userName, $this-> password); //選取資料庫 mysql_select_db("a4306868_data", $mylink); //指定提取資料的校對字元表 mysql_query("set character set big5"); $sql="select * from notedata where dateNum='" . $noteDate . "'"; $dataList=mysql_query($sql); if ($arr_result=mysql_fetch_array($dataList,MYSQL_BOTH)) { return $arr_result["note"]; }else{ return ""; } } //寫入事情的內容 function setNote($noteDate,$noteMemo){ //建立資料連結 $mylink = mysql_connect($this-> hostName, $this-> userName, $this-> password); //選取資料庫 mysql_select_db("a4306868_data", $mylink); //指定提取資料的校對字元表 mysql_query("set character set big5"); $sql="select * from notedata where dateNum='" . $noteDate . "'"; $dataList=mysql_query($sql); if ($arr_result=mysql_fetch_array($dataList,MYSQL_BOTH)) { $sql="update notedata set note='" . $noteMemo. "' where dateNum='" . $noteDate . "'"; mysql_query($sql); }else{ $sql="insert into notedata (note,dateNum) value('" . $noteMemo . "','" . $noteDate . "')"; mysql_query($sql); } } } ?> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.116.39.125

03/06 21:35, , 1F
編碼
03/06 21:35, 1F

03/06 21:40, , 2F
不好意思,本人是新手。若是編碼問題,如何在PHP中修改?或是
03/06 21:40, 2F

03/06 21:42, , 3F
這是提供免費網頁者的設定.(我無法做任何調整)?
03/06 21:42, 3F

03/06 22:46, , 5F
等等... 我搞錯了,妳亂掉的mysql的編碼,不是網頁的...
03/06 22:46, 5F

03/07 00:19, , 6F
mysql_query('SET NAMES utf8');
03/07 00:19, 6F

03/07 12:06, , 7F
網頁編碼、資料庫存放編碼、php操作mysql指定編碼
03/07 12:06, 7F

03/07 12:06, , 8F
三個一致就可以了
03/07 12:06, 8F

03/07 12:53, , 9F
註解寫的是錯的character set跟collation是不一樣的東 XD
03/07 12:53, 9F

03/09 07:06, , 10F
謝謝各位的建議!
03/09 07:06, 10F
文章代碼(AID): #1FLWbJnR (PHP)
文章代碼(AID): #1FLWbJnR (PHP)