[請益] mysql_fetch_array的問題

看板PHP作者 (紫苑紅風~)時間17年前 (2008/08/11 02:02), 編輯推噓1(101)
留言2則, 1人參與, 最新討論串1/1
比如說有這樣一個例子: <? 資料庫連線...(省略) for($index=0; $index<5; $index++){ $row = mysql_fetch_array($result); echo $row[name]; } ?> 這樣是可以的 可是換成 <? for($index=0; $index<5; $index++){ $row = mysql_fetch_array($result); } $x= 3 for($index=0; $index<$x; $index++){ echo $row[$index][name]; } ?> 為什麼也可以印出來呢? 我查了php文件裡面的mysql_fetch_array() 也沒看過可以存成$row的二維陣列說 被這個問題困擾了好久... 而且我後來印出來的都是亂碼 因為原本的php是從big5轉utf-8 可是我直接存utf-8的php又會印出亂碼... 可以請問大家嗎@@? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.194.85

08/11 02:41, , 1F
有關亂碼,try mysql_query('SET NAMES utf8');
08/11 02:41, 1F

08/11 02:41, , 2F
before you execute any query
08/11 02:41, 2F
文章代碼(AID): #18doqo05 (PHP)
文章代碼(AID): #18doqo05 (PHP)