[請益] 讀不到資料

看板PHP作者 (怎樣轉移檔案?)時間18年前 (2007/11/08 16:15), 編輯推噓2(202)
留言4則, 2人參與, 最新討論串1/2 (看更多)
我有一個資料庫,資料表匯出時的格式如下: -- phpMyAdmin SQL Dump -- version 2.11.0 -- http://www.phpmyadmin.net -- -- 主機: localhost -- 建立日期: Nov 08, 2007, 04:02 PM -- 伺服器版本: 4.1.20 -- PHP 版本: 5.0.4 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- 資料庫: `old` -- -- -------------------------------------------------------- -- -- 資料表格式: `faq_utf8` -- CREATE TABLE IF NOT EXISTS `faq_utf8` ( `id` mediumint(8) NOT NULL auto_increment, `title` varchar(50) NOT NULL default '請選擇主題', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; -- -- 列出以下資料庫的數據: `faq_utf8` -- INSERT INTO `faq_utf8` (`id`, `title`) VALUES (1, '規定'), (2, '訊息'), (3, '測試'); 網頁的內容如下: <? mysql_query("set names utf8"); mysql_query("character set utf8"); mysql_query("set character_set_client =utf8"); mysql_query("set collation_connection=utf8_general_ci"); mysql_query("set character_set_results =utf8"); mysql_query("set character_set_server = utf8"); mysql_query("set character_set_connection=utf8"); mysql_connect ('localhost','abcd','sir'); $sql_select="select * from faq_utf8 "; $result = mysql_db_query ('old', $sql_select); while ($row = mysql_fetch_object ($result)) { echo $row->title; //echo $row->fullname; echo "<hr>"; } mysql_free_result ($result); ?> 可是網頁呈現的卻是: ?? -------------------------------------------------------------------------------- ?? -------------------------------------------------------------------------------- ?? -------------------------------------------------------------------------------- 請問我哪一部份沒有注意到呢? 因為資料庫裡面有資料,也能在phpMyAdmin內順利顯示, 可是,不論IE或Firefox,都看不到內容,讓我很困惑,不知哪裡寫錯 我的sql檔案與網頁檔案,我放在 http://rapidshare.com/files/68239896/question_php.zip -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.109.139.91

11/08 16:38, , 1F
網頁編碼不對?
11/08 16:38, 1F

11/08 20:27, , 2F
sql載入檔要存成utf-8格式加上set names utf8
11/08 20:27, 2F

11/08 20:29, , 3F
才能確保資料以utf-8編碼存入 希望有幫到你
11/08 20:29, 3F

11/08 20:35, , 4F
對不起 我答非所問 一樓和下一篇是解答
11/08 20:35, 4F
文章代碼(AID): #17CiMZ6r (PHP)
討論串 (同標題文章)
文章代碼(AID): #17CiMZ6r (PHP)