資料庫和meta檔都設定utf8 網頁卻仍顯示亂碼 解決方式: 之前大部分其他網站都寫在config檔裡,所以沒有這樣的問題
if ( ! $db = mysql_pconnect( $sql_details['host'], $sql_details['user'], $sql_details['pass'] ) ) {
    //mysql_set_charset('utf8',$db);
    header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
    die( 'Could not open connection to server' );
}

if ( ! mysql_select_db( $sql_details['db'], $db ) ) {
    header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
    die( 'Could not select database' );
}

mysql_set_charset('utf8',$db);//強制mysql連線用utf8的方式
Previous
Next Post »