php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45921 Can't initialize character set hebrew (path: C:\mysql\\share\charsets\)
Submitted: 2008-08-26 12:01 UTC Modified: 2011-01-05 17:55 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: ymagriso at gmail dot com Assigned: mysql (profile)
Status: Not a bug Package: MySQLi related
PHP Version: 5.2.6 OS: win32 only
Private report: No CVE-ID: None
 [2008-08-26 12:01 UTC] ymagriso at gmail dot com
Description:
------------
I have Apache 2.2.9/PHP 5.2.6 and MySQL 5.0.67 installed on Windows XP/SP3.

Apache is installed in the following path: "C:\Apache2.2".
PHP is installed in the following path: "C:\PHP5".
MySQL is installed in the following path: "C:\MySQL5.0".

I am running the PHP script below and getting the error specified below. I could not find anywhere in the documentation how to troubleshoot this error.

Note, that when I connect with mysql as a client and check the "character_sets_dir" it shows the correct one:

mysql> show variables like "%character%";
+--------------------------+-----------------------------+
| Variable_name            | Value                       |
+--------------------------+-----------------------------+
| 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:\MySQL5.0\share\charsets\ |
+--------------------------+-----------------------------+
8 rows in set (0.00 sec)

mysql>

Therefore, I assume that the problem is not related to MySQL configuration, but to "MySQLi". However, the documentation does not show how to change the "character_sets_dir" for MySQLi.

(Also, the documentation advises:
"Note: This is the preferred way to change the charset. Using mysqli::query() to execute SET NAMES ..  is not reccomended."
However, SET NAMES works fine as a workaround to the problem.)

Reproduce code:
---------------
$db = new mysqli('host', 'username', 'password', 'database');
if(mysqli_connect_errno())
{
	printf("Error: could not connect to database! Please try again later.\n");
	return;
}

if(!$db->set_charset("hebrew"))
{
	printf("Error: could not load character set hebrew - %s\n", $db->error);
}

Expected result:
----------------
Character set of DB is changed to "hebrew" (and no error is shown).

Actual result:
--------------
I am getting the following error message:
"Error: could not load character set hebrew - Can't initialize character set hebrew (path: C:\mysql\\share\charsets\)"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-26 22:29 UTC] jani@php.net
Do you by any chance have two different mysql versions installed?
What does phpinfo() have to say in the MySQLi section about which client lib version is used..?
 [2008-08-27 08:07 UTC] ymagriso at gmail dot com
You are right.
phpinfo() shows the following in MySQLi section:

MysqlI Support	enabled
Client API library version 	5.0.51a
Client API header version 	5.0.51a
MYSQLI_SOCKET 	/tmp/mysql.sock

However, I downloaded the library along with the PHP installer from the following location:
http://il2.php.net/get/php-5.2.6-win32-installer.msi/from/a/mirror

I will try to download it again, re-install and then check whether the version was updated.
 [2008-08-28 18:37 UTC] ymagriso at gmail dot com
I un-installed PHP, downloaded the PHP installer again from another mirror and installed again.

However, the version of the client was still 5.0.51a (and I am still encountering the same problem).

Please, advise whether I am missing something.
 [2008-08-28 21:25 UTC] jani@php.net
IIRC, the SET NAMES doesn't actually do anything with Mysql 5.0 on client side..I might be wrong though. :)

Check that you really have it, run this in the mysql client:

mysql> SHOW CHARACTER SET;

And check your mysql config (my.cnf or whatever it's called in win32)
that it has the proper path for the charsets. It should be in [mysql] section. (mysql manual might help? :)
 [2008-08-29 07:08 UTC] ymagriso at gmail dot com
As I stated in the original message the SET NAMES actually works fine as a workaround (no error and the character set is changed to "hebrew").

As for the list of available character sets:

mysql> show character set;
+----------+-----------------------------+---------------------+--------+
| Charset  | Description                 | Default collation   | Maxlen |
+----------+-----------------------------+---------------------+--------+
| big5     | Big5 Traditional Chinese    | big5_chinese_ci     |      2 |
| dec8     | DEC West European           | dec8_swedish_ci     |      1 |
| cp850    | DOS West European           | cp850_general_ci    |      1 |
| hp8      | HP West European            | hp8_english_ci      |      1 |
| koi8r    | KOI8-R Relcom Russian       | koi8r_general_ci    |      1 |
| latin1   | cp1252 West European        | latin1_swedish_ci   |      1 |
| latin2   | ISO 8859-2 Central European | latin2_general_ci   |      1 |
| swe7     | 7bit Swedish                | swe7_swedish_ci     |      1 |
| ascii    | US ASCII                    | ascii_general_ci    |      1 |
| ujis     | EUC-JP Japanese             | ujis_japanese_ci    |      3 |
| sjis     | Shift-JIS Japanese          | sjis_japanese_ci    |      2 |
| hebrew   | ISO 8859-8 Hebrew           | hebrew_general_ci   |      1 |
| tis620   | TIS620 Thai                 | tis620_thai_ci      |      1 |
| euckr    | EUC-KR Korean               | euckr_korean_ci     |      2 |
| koi8u    | KOI8-U Ukrainian            | koi8u_general_ci    |      1 |
| gb2312   | GB2312 Simplified Chinese   | gb2312_chinese_ci   |      2 |
| greek    | ISO 8859-7 Greek            | greek_general_ci    |      1 |
| cp1250   | Windows Central European    | cp1250_general_ci   |      1 |
| gbk      | GBK Simplified Chinese      | gbk_chinese_ci      |      2 |
| latin5   | ISO 8859-9 Turkish          | latin5_turkish_ci   |      1 |
| armscii8 | ARMSCII-8 Armenian          | armscii8_general_ci |      1 |
| utf8     | UTF-8 Unicode               | utf8_general_ci     |      3 |
| ucs2     | UCS-2 Unicode               | ucs2_general_ci     |      2 |
| cp866    | DOS Russian                 | cp866_general_ci    |      1 |
| keybcs2  | DOS Kamenicky Czech-Slovak  | keybcs2_general_ci  |      1 |
| macce    | Mac Central European        | macce_general_ci    |      1 |
| macroman | Mac West European           | macroman_general_ci |      1 |
| cp852    | DOS Central European        | cp852_general_ci    |      1 |
| latin7   | ISO 8859-13 Baltic          | latin7_general_ci   |      1 |
| cp1251   | Windows Cyrillic            | cp1251_general_ci   |      1 |
| cp1256   | Windows Arabic              | cp1256_general_ci   |      1 |
| cp1257   | Windows Baltic              | cp1257_general_ci   |      1 |
| binary   | Binary pseudo charset       | binary              |      1 |
| geostd8  | GEOSTD8 Georgian            | geostd8_general_ci  |      1 |
| cp932    | SJIS for Windows Japanese   | cp932_japanese_ci   |      2 |
| eucjpms  | UJIS for Windows Japanese   | eucjpms_japanese_ci |      3 |
+----------+-----------------------------+---------------------+--------+
36 rows in set (0.05 sec)

mysql>

The character set "hebrew" is there.
As for your last request, the "my.ini" does not include any statement regarding the "character_sets_dir".
Adding it as advised in MySQL documentation does not help in this case.
 [2008-08-31 12:54 UTC] ymagriso at gmail dot com
I just wanted to add another comment.

I called the following queries via PHP using MySQLi:
1) show character set
2) show variables like "%character%"

Surprisingly, I got exactly the same results as via "mysql" client.
So, the problem seems to be related to the mysqli::set_charset(). I could not find anywhere in "php.ini" or "my.ini" (MySQL) that path defined ("C:\mysql\\share\charsets\").

My guess is that the path "C:\mysql\\share\charsets\" is hardcoded within the method in the MySQLi library (php_mysqli.dll).
 [2008-09-01 20:28 UTC] ymagriso at gmail dot com
I found a solution to the problem.
The problem is related to php_mysqli.dll that comes with the PHP installer package.

I downloaded another version of the DLL from MySQL website:
http://dev.mysql.com/get/Downloads/Connector-PHP-mysqlnd/php_5.2.1-mysqlnd-5.0.1-beta.zip/from/pick

I replaced the "faulty" DLL (that came with the PHP installer package) with the one I downloaded from MySQL website, then restarted the webserver and the problem was gone.

I would recommend to check the php_mysqli.dll that comes with the PHP installer package.
 [2008-11-21 19:21 UTC] pajoye@php.net
All mysql extensions use the same library. Assigned back to "mysql" and let them try to figure what's wrong here.
 [2009-04-27 11:25 UTC] johannes@php.net
Please use $db->options(MYSQLI_SET_CHARSET_NAME, 'C:\\MySQL5.0\\share\\charsets'); to properly set the charset path.
 [2009-04-27 11:54 UTC] johannes@php.net
Sorry, my bad, confused names,  SET_CHARSET_DIR is the one i meant, but that isn't exported, checking whether there's a reason or just  oversight.
 [2010-08-05 15:38 UTC] johannes@php.net
-Status: Assigned +Status: Feedback
 [2010-08-05 15:38 UTC] johannes@php.net
Please mind the last comments and test a more recent snapshot/release.
 [2010-09-27 14:36 UTC] andrey@php.net
Automatic comment from SVN on behalf of andrey
Revision: http://svn.php.net/viewvc/?view=revision&revision=303781
Log: Fixed bug #45921 (Can't initialize character set hebrew)
 [2010-09-27 14:37 UTC] andrey@php.net
Automatic comment from SVN on behalf of andrey
Revision: http://svn.php.net/viewvc/?view=revision&revision=303782
Log: Fixed bug #45921 (Can't initialize character set hebrew)
sorry for committing it separated
 [2011-01-05 17:54 UTC] andrey@php.net
Seems like libmysql issue. If still persists open a bug report at http://bugs.mysql.com
 [2011-01-05 17:55 UTC] andrey@php.net
-Status: Feedback +Status: Bogus
 [2011-01-05 17:55 UTC] andrey@php.net
see previous comment
 [2011-05-05 12:30 UTC] o dot kochetilov at gmail dot com
there is a solution - put files from \share\charsets folder in your C:\MySQL5.0 
directory into C:\MySQL\share\charsets directory.
Don't forget to restart you webserver.
I guess it's a bug into libmysql.dll
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC