Bug #11362 php connect to mysql and client connection charset is wrong
Submitted: 15 Jun 2005 22:04 Modified: 21 Jun 2005 13:12
Reporter: István Zsoldos Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.12a OS:Windows (win2000/xp)
Assigned to: CPU Architecture:Any

[15 Jun 2005 22:04] István Zsoldos
Description:
Hi,

I am using on windows 2000 SP4 and xitami 2.5c2 webserver.
Mysql 4.1.12a installes c:\MySQL
PHP5 installed. (I tried PHP4 and older mysql releases).
I try to use php_myqsl and php_mysqli with the same result.
I resolved the problem partially....
My windows locale hungarian all html header iso-8859-2.

my.ini contains settings below
....
[client]
port=3306
default-character-set=latin2
[mysqld]
port=3306
basedir="C:/MySQL/"
datadir="C:/MySQL/Data/"
character_sets-dir=c:/MySQL/share/charsets/
default-character-set=latin2
default-collation=latin2_hungarian_ci
language=C:/MySQL/share/hungarian/
[mysql]
prompt=\_[\d]=>
character-sets-dir=C:/MySQL/share/charsets/
default-character-set=latin2
....

After php mysql_connect() the connection encoding ??? latin1_swedish_ci
if i copy libmysql.dll from c:\mysql\bin to c:\php ??? latin1
I use iconv functions and special chars áéőúűüöíó correctly appear in the 
web application. (input text...) if i insert with php mysq_query.
mysql query browser displays records with correct strings.

BUT

I like to use mysql client in win dos consol. (cmd) 
code page:852

The inserted records display absolutely wrong. I dont understand...
If I insert in this command consol (mysql) with good strings (áűűőú...)
will display wrong in php web application....vice versa.
If I like to use win/dos  consol applications to import records from text files
not work properly and mixing chars. 
Maybe it depends on conversion between code pages DOS <->Windows but 
I dont understand why I can't change php mysql client connection charset encoding to latin2??? I think this resolve the problem.

Many thanks for your debugging time....
Best regards

Istvan Zsoldos

How to repeat:
everytime :(

Suggested fix:
?
[15 Jun 2005 22:07] István Zsoldos
Oops i execute mysqld-nt.exe --console option in command prompt not as service.
[21 Jun 2005 13:12] Hartmut Holzgraefe
The client library bundled with PHP does not read the my.cnf option file,
you have to set the charater set explicitly for each connection using

  SET NAMES latin2;