作者ginnz (go)
看板PHP
標題[請益] 輸入的中文_輸出均為問號
時間Tue Mar 6 20:55:45 2012
製作類似行事曆的網頁
在前端網頁上 輸入中文,重新按鈕顯示剛剛輸入的內容,凡中文的部分,
都以"?"顯示每個中文字
到後台的資料庫中 新增中文的資料 才可在網頁端 看到正常的中文輸出
(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
1F:推 UniFish:編碼 03/06 21:35
2F:→ ginnz:不好意思,本人是新手。若是編碼問題,如何在PHP中修改?或是 03/06 21:40
3F:→ ginnz:這是提供免費網頁者的設定.(我無法做任何調整)? 03/06 21:42
5F:→ LaPass:等等... 我搞錯了,妳亂掉的mysql的編碼,不是網頁的... 03/06 22:46
6F:→ Canboo:mysql_query('SET NAMES utf8'); 03/07 00:19
7F:推 UniFish:網頁編碼、資料庫存放編碼、php操作mysql指定編碼 03/07 12:06
8F:→ UniFish:三個一致就可以了 03/07 12:06
9F:→ buganini:註解寫的是錯的character set跟collation是不一樣的東 XD 03/07 12:53
10F:→ ginnz:謝謝各位的建議! 03/09 07:06