Doc #52453 [Asn->Ver]: Connection charset seems arbitrary

From: Date: Wed, 18 Aug 2010 10:44:53 +0000
Subject: Doc #52453 [Asn->Ver]: Connection charset seems arbitrary
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-4879@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52453&edit=1 ID: 52453 Updated by: andrey@php.net Reported by: jeroen at asystance dot nl Summary: Connection charset seems arbitrary -Status: Assigned +Status: Verified Type: Documentation Problem Package: MySQLi related Operating System: Linux PHP Version: 5.3.3 -Assigned To: mysql +Assigned To: Block user comment: N New Comment: the doc team should take over this one Previous Comments: ------------------------------------------------------------------------ [2010-08-18 12:44:19] andrey@php.net You can overwrite the charset, when using mysqlnd, by calling mysqli_options on a connection created with mysqli_init() but still not connected with mysqli_real_connect(). In this case mysqlnd won't assume the server default charset. ------------------------------------------------------------------------ [2010-08-13 12:43:18] jeroen at asystance dot nl A ha! That's exactly the documentation I was looking for online. I've changed the type to "documentation problem" and think the proper way to resolve this bug is to add this documentation. I was using mysqlnd by the way (standard setting on ubuntu I guess). ------------------------------------------------------------------------ [2010-08-13 12:00:27] andrey@php.net Are you using mysqlnd or libmysql. Libmysql uses its default charset, or set in my.cnf or by explicit call to mysqli_options before calling mysqli_real_connect, but after mysqli_init(). If you use mysqlnd, in this case mysqlnd always assumes the server default charset. This charset is sent during connection hand-shake/authentication and mysqlnd assumes it. ------------------------------------------------------------------------ [2010-07-27 12:23:25] gerben at asystance dot nl I connected to the same remote database from a Windows/WAMP system and got exactly the same results. ------------------------------------------------------------------------ [2010-07-27 12:09:15] jeroen at asystance dot nl BTW: when I make the same connection as in the first example, but use the mysql CLI client instead of php, I get mysql> SHOW VARIABLES LIKE 'character_set%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ So PHP's mysql_connect() behaves differently from mysql cli! ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=52453 -- Edit this bug report at http://bugs.php.net/bug.php?id=52453&edit=1

« previous php.doc.bugs (#4879) next »