Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Štvrtok, 18. apríl 2024
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  mysql_set_charset

phpMyEdit Configuration     mysql_set_charset
Odoslať novú tému   Odpovedať na tému    
 
MarkDHamill     Založený: 30.01.2010   Príspevky: 8  
Príspevok Zaslal: 2010-05-31 16:17
Návrat hore  Odpovedať s citátom     

Where would I add the following statement?

Kód:
mysql_set_charset('utf8');


I've had to add this statement to other scripts I have written against my database because it appears my MySQL installation will not output UTF-8 by default. The result is funny characters on output when I am showing certain words in French.

I realize that the setup program can create headers that can specify the page is in UTF-8 but it alone will not solve my problem. I also have to tell MySQL to send data in UTF-8.

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2010-06-02 12:05
Návrat hore  Odpovedať s citátom     

See the article referenced at
http://opensource.platon.sk/forum/projects/viewtopic.php?t=1152728

 
MarkDHamill     Založený: 30.01.2010   Príspevky: 8  
Príspevok Zaslal: 2010-06-02 13:28
Návrat hore  Odpovedať s citátom     

However, I don't think this is going to help because as best I can tell the data is encoded correctly in the database.

Collation information:

Kód:
phpBB3      utf8_general_ci


Varchar columns have the following collation:

Kód:
utf8_general_ci


In addition using a tool like phpMyAdmin I can edit data successfully in UTF-8.

It's something about MySQL not outputting data in UTF-8 by default. Since I am using shared hosting I don't think I can edit the my.cnf file. So I need to issue a statement to set the output type, which works. So I think if I add a statement like this at the appropriate place in the phpMyEdit code my problem will mysteriously disappear, as it has in the past.

Kód:
mysql_set_charset('utf8');


 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2010-06-02 16:16
Návrat hore  Odpovedať s citátom     

The correct META tags must appear in your HTML code, for example:


Kód:
<meta http-equiv="charset" content="UTF-8">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">


 
MarkDHamill     Založený: 30.01.2010   Príspevky: 8  
Príspevok Zaslal: 2010-06-03 22:48
Návrat hore  Odpovedať s citátom     

I'm sorry, I added both those lines to my HTML and they did not solve the problem.

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2010-06-03 22:56
Návrat hore  Odpovedať s citátom     

If the data was *always* UTF8 (never in Latin1 or any other format), the appropriate META tags are in place, and the appropriate queries are issued after the db connection, then it should be working. Are you sure your PHP version supports the function referenced above?

http://www.oreillynet.com/onlamp/blog/2006/01/turning_mysql_data_in_latin1_t.html

Dump your web browser cache, close the browser, and re-open (since sometimes they misbehave and display cached pages even on reload).

 
MarkDHamill     Založený: 30.01.2010   Príspevky: 8  
Príspevok Zaslal: 2010-06-03 23:30
Návrat hore  Odpovedať s citátom     

I tried it in another browser and the same problem persists.

You can see it here. As you can see from the source code, the meta tags are applied.

Thanks for your help.

 
MarkDHamill     Založený: 30.01.2010   Príspevky: 8  
Príspevok Zaslal: 2010-06-05 23:34
Návrat hore  Odpovedať s citátom     

I seem to have fixed the problem by modifying the function sql_connect in phpMyEdit.class.php as follows:

Kód:
   function sql_connect() /* {{{ */
   {
      $this->dbh = @ini_get('allow_persistent')
         ? @mysql_pconnect($this->hn, $this->un, $this->pw)
         : @mysql_connect($this->hn, $this->un, $this->pw);
      mysql_set_charset('utf8');
   } /* }}} */


 
jdevlieghere     Založený: 30.04.2012   Príspevky: 1  
Príspevok Zaslal: 2012-04-30 11:06
Návrat hore  Odpovedať s citátom     

This last suggestion did the trick for me too - thx!

By the way, the official PHP documentation states:

"This (= mysql_set_charset) is the preferred way to change the charset. Using mysql_query() to execute SET NAMES .. is not recommended."
http://php.net/manual/en/function.mysql-set-charset.php

 
gutenzwerg     Založený: 29.03.2012   Príspevky: 4  
Príspevok Zaslal: 2013-05-11 17:02
Návrat hore  Odpovedať s citátom     

This last suggestion did the trick for me too - thx!

gutenzwerg

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov