View Single Post

   
  #19 (permalink)  
Old 06-13-2008, 02:59 PM
Marc
 
Posts: n/a
Default Re: Mysql database in UTF8, PHP shoud show latin1, but it doesn't

Jerry Stuckle schrieb:
> Marc wrote:
>> Jerry Stuckle schrieb:
>>> Marc wrote:
>>>> alex schrieb:
>>>>>
>>>>> I made a simple script in PHP to dump data from tables which had
>>>>> non standard characters. But the resulting page is viewed correctly
>>>>> in iso-8859-1 encoding and not in UTF-8.
>>>>>
>>>>> At this moment i'm clueless were the problem lies.
>>>>
>>>> Hello,
>>>>
>>>> well, first of all, I'm newbie with MYSQL & Co., I have read all
>>>> answers and followed the link reading them all carefully. I suppose
>>>> I understand the matter.
>>>>
>>>> I have apparently the same problem as Alex has. But my connection is
>>>> in UTF-8 and I need ISO-8859-1.
>>>>
>>>> The problem accrued as I've moved from my webspace to a vServer.
>>>>
>>>> The old configuration shown by phpMyAdmin on MySQL 4.1.13 is:
>>>>
>>>> character set client utf8
>>>> (Globaler Wert) latin1
>>>> character set connection utf8
>>>> (Globaler Wert) latin1
>>>> character set database latin1
>>>> character set results utf8
>>>> (Globaler Wert) latin1
>>>> character set server latin1
>>>> character set system utf8
>>>> collation connection utf8_general_ci
>>>> (Globaler Wert) latin1_swedish_ci
>>>> collation database latin1_swedish_ci
>>>> collation server latin1_swedish_ci
>>>>
>>>> The new configuration shown by phpMyAdmin on my new MySQL 5.0.32 is
>>>> exactly the same, the I set "SET NAMES latin1" via mysql-shell.
>>>>
>>>> BUT:
>>>>
>>>> Making "SHOW VARIABLES" at mysql-shell gives:
>>>>
>>>> character_set_client latin1
>>>> character_set_connection latin1
>>>> character_set_database latin1
>>>> character_set_filesystem binary
>>>> character set results latin1
>>>> character set server latin1
>>>> character set system utf8
>>>> collation connection latin1_swedish_ci
>>>> collation database latin1_swedish_ci
>>>> collation server latin1_swedish_ci
>>>>
>>>> asking for the values by PHP gives:
>>>>
>>>> character_set_client utf8
>>>> character_set_connection utf8
>>>> character_set_database latin1
>>>> character_set_filesystem binary
>>>> character_set_results utf8
>>>> character_set_server latin1
>>>> character_set_system utf8
>>>> collation_connection utf8_general_ci
>>>> collation_database latin1_swedish_ci
>>>> collation_server latin1_swedish_ci
>>>>
>>>> I need the character_set_client and character_set_connection in latin1.
>>>>
>>>> The HTTP header sends to the browser ISO-8859-15. That should stay
>>>> so, because about 2.000 html pages are coded in this. I don't care
>>>> for the DB contect, then I have it local in some programm. My only
>>>> wish is to establish a working-encoding-connection between the PHP
>>>> and DB.
>>>>
>>>> Can You please tell what exactly I have to do? Please, understand I
>>>> can't reprogramm the application, I even don't want to, because it
>>>> worked before. I'm quit sure it's not correct setted up.
>>>>
>>>> Thanks a lot in advance!!!
>>>>
>>>> Regards
>>>>
>>>> Marc
>>>>
>>>
>>> Oops, I didn't notice you crossposted this to comp.databases.mysql.
>>>
>>> You indicated you had "non-standard" characters in the database. The
>>> first question is - what charset is the data in the database in? And
>>> exactly what are these "non-standard" characters?
>>>

>>
>> Hello Jerry,
>>
>> sorry for crossposting. I think it's not only MYSQL problem, but also
>> PHP problem.
>>
>> I have German umlauts in there. I guess the old DB used latin1 and the
>> new one uses UTF-8 for internal corresponding.
>>
>> As I have found it, it acctually doesn't matter how the DB corresponds
>> internal, then it's able to encode by request sent by client. And
>> that's the point, I guess PHP doesn't say which encoding it would like
>> to use. Or maybe it's enough to tell DB which encoding it should
>> normally use talking to anything from outside.
>>
>> Right?
>>
>> So, I'm sorry for crossposting but I guess it's a mysql-php-problem.
>>
>> Thanks a lot for Your responce.
>>
>>
>> Regards,
>>
>> Marc
>>

>
> Marc,
>
> No, it's my fault for not noticing the cross-posting in the first place.
>
> You probably now have a mismatch between your connection and your table.
> Besides the charset used by the table, you have a charset used by the
> connection. I suspect you have a mismatch here. After connecting, call:
>
> mysql_query("SET NAMES 'latin1'");
>
> This should also set your connection to latin1.
>


Jerry,

that's what I guess the problem is.

I've tried to call the command at the mysql-shell... and got error 1064
(42000). Should it be called via the php script perhaps? That's not that
comfortable way for me...

Regards,

Marc
Reply With Quote