Advanced search  

News:

cpg1.5.46 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter recently discovered vulnerabilities. It is important that all users who run version cpg1.5.44 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Cyrillic characters in database  (Read 18523 times)

0 Members and 1 Guest are viewing this topic.

sard

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
Cyrillic characters in database
« on: June 05, 2009, 02:43:39 pm »

Hi,
Becuase my native language is one of Cyrillic group of languages, albums, categories, and some files are writtein with cyrillic charset. Their view (utf-8) in browser is ok, but in database even utf-8 is selected they are unreadable. If i write them in database with cyrillic letters then opposite they become unreadable in browser show of the gallery. Can you tell me how to show the both sides, databes and gallery in browser with proper cyrillic charset.

Thank you
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Cyrillic characters in database
« Reply #1 on: June 05, 2009, 03:00:12 pm »

Use cyrillic or unicode collation for your database as well. Not sure what you mean: how do you access the database? You'll need a tool that makes sure that the database content doesn't display "garbled", as you can't directly look at the database.
« Last Edit: June 06, 2009, 12:37:34 am by Joachim Müller »
Logged

sard

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
Re: Cyrillic characters in database
« Reply #2 on: June 05, 2009, 03:52:54 pm »

I use phpmyadmin. All charset through phpmyadmin are set to utf8_unicode_ci. Still everything cyrillic is unreadable (nonmeaningfull). If i write them in cyrillic then they stay ok, but opposite they become unreadable (nonmeaningfull) in gallery (browser) with the same supstitute characters.

Logged

Jaguar13

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Cyrillic characters in database
« Reply #3 on: June 12, 2009, 11:42:02 pm »

I have same problems with the Russian language :(

If I put the Russian text using coppermine interface, I am getting database records in phpmyadmin looks like you are viewing UTF-8 using CP1251 codepage. I.e. if I type "Галерея улик e-mafia", I am getting "Галерея улик e-mafia" in the phpmyadmin. If I change value in the phpmyadmin, I am getting like "������� ���� e-mafia" in the coppermine.

MySQL charset:  UTF-8 Unicode (utf8)
MySQL connection collation: utf8_unicode_ci

The same problem I am getting the trying to bridge coppermine to phpBB 2.0.18, all users, who have Russian names displayed with ���� characters in Coppermine :(.
Logged

Jaguar13

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Cyrillic characters in database
« Reply #4 on: June 12, 2009, 11:46:38 pm »

Sorry forget to add information about mysql and phpmyadmin versions:

Server version: 4.1.22-log
MySQL client version: 4.1.22
phpMyAdmin - 2.11.9.5
Used PHP extensions: mysql
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Logged

Jaguar13

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Cyrillic characters in database
« Reply #6 on: June 13, 2009, 12:32:07 am »

I found the reason of this:
Looks like webhoster set up mysql to get out data by default in the CP1251 encoding. I.e. character_set_client='cp1251', character_set_results='cp1251', character_set_connection='cp1251'.

I solve this problem by adding "SET NAMES 'utf8'" query to the cpg_db_connect function in functions.inc.php
Code: [Select]
function cpg_db_connect()
{
        global $CONFIG;
        $result = @mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
        if (!$result) {
                return false;
        }
        if (!mysql_select_db($CONFIG['dbname']))
                return false;
        mysql_query("SET NAMES 'utf8'", $result);
        return $result;
}

I think instead of 'utf8', i should put the variable, responsible in Coppermine for Character encoding.
But I don't know it's name, and looks like it is stored in database, so results might be unpredictable.
Logged

Old RMN

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • www.primethai.com -Discover Thailand individually-
Re: Cyrillic characters in database
« Reply #7 on: July 09, 2010, 07:24:53 am »

Jaguar13, your solution is totally amazing and helped me resolve a long, long search.

Hint for all phpmyadmin users stuck with charset display problems who already have checked the collation settings of their own database and its tables:

This hack does not only apply to Cyrillic characters and not only to your particular provider.

Thank you very much!
Logged
Sometimes to find the way home one has to leave it.

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Cyrillic characters in database
« Reply #8 on: July 09, 2010, 07:49:53 am »

I think instead of 'utf8', i should put the variable, responsible in Coppermine for Character encoding.
But I don't know it's name, and looks like it is stored in database, so results might be unpredictable.
The variable is $CONFIG['charset']
However, I can see another issue: I'm not sure that all webhosted users will have permission on database level to perform the SET NAMES query.

@devs: do you think that this should be added to the core? What happens if a user doesn't have permission to execute that query?
Logged

sard

  • Coppermine newbie
  • Offline Offline
  • Posts: 14
Re: Cyrillic characters in database
« Reply #9 on: July 09, 2010, 02:19:50 pm »

Thank you for solution.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Cyrillic characters in database
« Reply #10 on: July 09, 2010, 06:31:43 pm »

Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 20 queries.