國外開發的系統做了語系 utf-8 格式中文化處理之後使用系統輸入中文資料,使用 phpMyAdmin 連接 MySQL 資料庫查看還是會有儲存亂碼的問題。所以還是自行指定 Zen Cart 的資料庫連線過程會比較妥當。

請修改 includes\classes\db\mysql 目錄下的 query_factory.php 檔案,尋找下列程式碼段落:

1
2
3
4
5
6
7
      if (@mysql_select_db($zf_database, $this->link)) {
        $this->db_connected = true;
        return true;
      } else {
        $this->set_error(mysql_errno(),mysql_error(), $zp_real);
        return false;
      }

將其修改成

1
2
3
4
5
6
7
8
9
10
11
      if (@mysql_select_db($zf_database, $this->link)) {
        $this->db_connected = true;
       // *** Add Start ***
       mysql_query("SET NAMES 'utf8'", $this->link);
       mysql_query("SET CHARACTER SET UTF8", $this->link);
       // *** Add End ***
        return true;
      } else {
        $this->set_error(mysql_errno(),mysql_error(), $zp_real);
        return false;
      }

編輯儲存後再開始輸入中文資料就不會有亂碼問題,可以用 phpMyAdmin 確認是否正常顯示喔。