MantisBT - Pending Requests
View Issue Details
0000587Pending RequestsCore Infrastructurepublic2010-09-29 21:382014-08-16 18:21
Reportersciciphy 
Assigned Topedroa 
PrioritynormalSeverityminorReproducibilityN/A
StatusfeedbackResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000587: mysql can't read chinese
Descriptionenvironment:

centos 5.5
phpmyadmin 3.3.4
mysql 5.0.77


1. /etc/my.cnf
add
Code:

[mysqld]
default-character-set=utf8
init_connect="SET NAMES UTF8;"
[client]
default-character-set=utf8


2. go back to phpmyadmin, in Run SQL query/queries on server "localhost":
type
Code:
SHOW VARIABLES LIKE '%character%'


make sure you see
Code:
character_set_client utf8
character_set_connection utf8
character_set_database utf8
character_set_filesystem binary
character_set_results utf8
character_set_server utf8
character_set_system utf8
character_sets_dir c:\wamp\bin\mysql\mysql5.1.36\share\charsets\


3. includes\db_adodb.php

Code:

function db_connect($host = 'localhost', $dbname, $user = 'root', $passwd = '', $persist = false) {
   global $db, $ADODB_FETCH_MODE;

   switch (strtolower(trim(w2PgetConfig('dbtype')))) {
      case 'oci8':
      case 'oracle':
         if ($persist) {
            $db->PConnect($host, $user, $passwd, $dbname) or die('FATAL ERROR: Connection to database server failed');
         } else {
            $db->Connect($host, $user, $passwd, $dbname) or die('FATAL ERROR: Connection to database server failed');
         }
         if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE', 0);
         break;
      default:
      //mySQL
         if ($persist) {
            $db->PConnect($host, $user, $passwd, $dbname) or die('FATAL ERROR: Connection to database server failed');
         } else {
            $db->Connect($host, $user, $passwd, $dbname) or die('FATAL ERROR: Connection to database server failed');
         }
//////////////PLEASE ADD THIS CODE/////////////////////
         mysql_query("SET NAMES 'utf8'");
///////////////////////////////////////////////////////////////
   }

   $ADODB_FETCH_MODE = ADODB_FETCH_BOTH;
}


then~ your mysql will display Chinese character properly now! congrat!!!
TagsNo tags attached.
related to 0000598feedback caseydk Pending Requests adodb-mysql does not set default character set for db connection, this can lead in unusable database content 
related to 0000632closed pedroa v2.3 Release (Closed) Print function produces wrong charaters 
Attached Files

Notes
(0001320)
pedroa   
2010-10-26 06:35   
Don't blame mysql, I can't read Chinese either :)

Can you please check if your web2Projects tables are encoded utf8?
Something like: utf8 COLLATE utf8_general_ci

Thanks,

Pedro A.
(0001374)
caseydk   
2010-11-26 07:25   
sciciphy, any update on this one?

I don't know enough about character sets to be helpful..

Issue History
2010-09-29 21:38sciciphyNew Issue
2010-10-19 11:25pedroaStatusnew => assigned
2010-10-19 11:25pedroaAssigned To => pedroa
2010-10-26 06:33pedroaRelationship addedrelated to 0000598
2010-10-26 06:35pedroaNote Added: 0001320
2010-10-26 06:35pedroaStatusassigned => feedback
2010-11-25 02:47pedroaRelationship addedrelated to 0000632
2010-11-26 07:25caseydkNote Added: 0001374
2010-12-28 20:41caseydkCategory-- none specified -- => Core Infrastructure
2014-08-16 18:21caseydkCategoryGeneral => Core Infrastructure