萬盛學電腦網

 萬盛學電腦網 >> 網絡編程 >> php編程 >> php連mysql用 utf-8編碼亂碼怎麼辦

php連mysql用 utf-8編碼亂碼怎麼辦

   1.修改my.ini:[mysql]default-character-set=utf8[mysqld]default-character-set=utf8default-storage-engine=MyISAM在[mysqld]下加入:default-collation=utf8_bininit_connect='SET NAMES utf8'

  2.在需要做數據庫操作的php程序前面加上mb_internal_encoding('utf-8');

  3.create table最後邊加上ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin

  4.phpMyAdmin/config.inc.php

  $cfg['DefaultCharset'] = 'utf-8';$cfg['RecodingEngine'] = 'iconv';

  5.phpMyAdmin/libraries/string.lib.php將第41行的mb_internal_encoding($GLOBALS['charset']);改為:mb_internal_encoding('utf-8');

  6.phpAdmin導出數據時把"二進制區域使用十六進制顯示"的勾去掉

copyright © 萬盛學電腦網 all rights reserved