|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#26 |
|
Messages: n/a
Hébergeur: |
Marc wrote:
> Jerry Stuckle schrieb: >> Marc wrote: >>> 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 >>> >> >> This statement is connection specific. You need to call it after >> connecting, and every time after connecting. Calling it from the >> command line only sets it for that connection; it won't set it for >> your PHP script, since it uses a different connection. >> >> But your error message by itself is meaningless. What is the >> statement you're entering, and what is the entire error message you >> get? It works fine for me. >> > > > I have connected with my server via putty, have logged in. Then logged > in into mysql: > > # mysql --password=mypassword --user=myuser [enter] > > Welcome to the MySQL monitor. Commands end with ; or \g. > Your MySQL connection id is 246 > Server version: 5.0.32-Debian_7etch5-log Debian etch distribution > > Type ';' or '\h' for . Type '\c' to clear the buffer. > > mysql> mysql_query("SET NAMES 'latin1'"); [enter] > > ERROR 1064 (42000): Fehler in der SQL-Syntax. Bitte die korrekte Syntax > im Handbuch nachschlagen bei 'mysql_query("SET NAMES 'latin1'")' in Zeile 1 > mysql> > > How can I change the connection permamently for php? Is it possible? > Without changing the scripts... > No, mysql_query() is a PHP function call, not a MySQL statement. What you need is just mysql>SET NAMES 'latin1'; The easiest way to change startup values is to go into MySQL Administrator, go to Service Control and click on the Configure Service tab. Then set the Localization section to the charset you wish. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#27 |
|
Messages: n/a
Hébergeur: |
Greetings, Marc.
In reply to Your message dated Monday, June 9, 2008, 21:59:24, > AnrDaemon schrieb: >> Greetings, Marc. >> In reply to Your message dated Monday, June 9, 2008, 19:31:01, >> >>>> You have the answer, but apparently lost it in your explanation. I'll quote: >>>> >>>>> 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. >>>> You must tell to server, what encoding you want, every time you connecting to >>>> database. >>>> Just add execution of 'SET NAMES latin1 COLLATE whatever_collation_you_need' >>>> statement right after the moment you have connected to database in your script. >> >>> thanks a lot for this advice. But it's not possible to change the whole >>> project for this. That's why I would like to set it generally up. On the >>> other side, I don't need any other encoding. >> >> You lost the point. >> It is not "changing the whole project", it is the action that project must do >> once in only one script - one that establishing connection to database. >> It is, literally, one line of code to add to whole your project, and it will >> serve you to the end of times. > that seems that easy, but it cannot be the cleanest way. I don't feel so > comfortable about it. It has worked already. I just would like to set > everything right up. It has worked already just because server was configured to work that way. It was a 4.0 server most likely, or server config have had an init_connect option set. Your argument "it was worked already" pointless, because environment have changed. You have only two ways to solve your problem. 1. I think it is right way. Adapt environment for your needs (by changing connection encoding every time you connect to database, it is one line of code in one single file, or in few files, if you are not using some sort of abstraction layer) - it will work as long as you are using MySQL servers for your database. They may have any settings on their own, but you'll have what you need in your script all the time. 2. Hard and one that I not considering acceptable for myself. Change your scripts to handle current database output encoding. It will strike just about every line of your code, in simple words - it will require to rewrite about half of your project. > I'm sending the data from some external DB by one php script and I'm > trying to add this simple line to it... It's gonna take some time, I to > new on this stuff. I'm gonna report. It's simple as find-replace ![]() Locate the point in your (key word - your) script, where you are using mysql_connect(). Add mysql_query('SET NAMES latin1'); Right after calling mysql_connect(). It should work. If you are using some sort of abstraction layer, it may be a bit different, but not harder. -- Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru> |
|
|
|
#28 |
|
Messages: n/a
Hébergeur: |
AnrDaemon schrieb:
> Greetings, Marc. > In reply to Your message dated Monday, June 9, 2008, 21:59:24, > >> AnrDaemon schrieb: >>> Greetings, Marc. >>> In reply to Your message dated Monday, June 9, 2008, 19:31:01, >>> >>>>> You have the answer, but apparently lost it in your explanation. I'll quote: >>>>> >>>>>> 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. >>>>> You must tell to server, what encoding you want, every time you connecting to >>>>> database. >>>>> Just add execution of 'SET NAMES latin1 COLLATE whatever_collation_you_need' >>>>> statement right after the moment you have connected to database in your script. >>>> thanks a lot for this advice. But it's not possible to change the whole >>>> project for this. That's why I would like to set it generally up. On the >>>> other side, I don't need any other encoding. >>> You lost the point. >>> It is not "changing the whole project", it is the action that project must do >>> once in only one script - one that establishing connection to database. >>> It is, literally, one line of code to add to whole your project, and it will >>> serve you to the end of times. > >> that seems that easy, but it cannot be the cleanest way. I don't feel so >> comfortable about it. It has worked already. I just would like to set >> everything right up. > > It has worked already just because server was configured to work that way. > It was a 4.0 server most likely, or server config have had an init_connect > option set. Your argument "it was worked already" pointless, because > environment have changed. > > You have only two ways to solve your problem. > 1. I think it is right way. > Adapt environment for your needs (by changing connection encoding every time > you connect to database, it is one line of code in one single file, or in few > files, if you are not using some sort of abstraction layer) - it will work as > long as you are using MySQL servers for your database. They may have any > settings on their own, but you'll have what you need in your script all the > time. > > 2. Hard and one that I not considering acceptable for myself. > Change your scripts to handle current database output encoding. It will strike > just about every line of your code, in simple words - it will require to > rewrite about half of your project. > >> I'm sending the data from some external DB by one php script and I'm >> trying to add this simple line to it... It's gonna take some time, I to >> new on this stuff. I'm gonna report. > > It's simple as find-replace ![]() > Locate the point in your (key word - your) script, where you are using > mysql_connect(). > Add > mysql_query('SET NAMES latin1'); > Right after calling mysql_connect(). > > It should work. > > If you are using some sort of abstraction layer, it may be a bit different, > but not harder. > Adding mysql_query didn't work, I mean it didn't change anything. The Umlauts are still wrong. I'm really fed up. It makes me sick. Thanks a lot for Your hints! |
|
|
|
#29 |
|
Messages: n/a
Hébergeur: |
Jerry Stuckle schrieb:
> Marc wrote: >> Jerry Stuckle schrieb: >>> Marc wrote: >>>> 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 >>>> >>> >>> This statement is connection specific. You need to call it after >>> connecting, and every time after connecting. Calling it from the >>> command line only sets it for that connection; it won't set it for >>> your PHP script, since it uses a different connection. >>> >>> But your error message by itself is meaningless. What is the >>> statement you're entering, and what is the entire error message you >>> get? It works fine for me. >>> >> >> >> I have connected with my server via putty, have logged in. Then logged >> in into mysql: >> >> # mysql --password=mypassword --user=myuser [enter] >> >> Welcome to the MySQL monitor. Commands end with ; or \g. >> Your MySQL connection id is 246 >> Server version: 5.0.32-Debian_7etch5-log Debian etch distribution >> >> Type ';' or '\h' for . Type '\c' to clear the buffer. >> >> mysql> mysql_query("SET NAMES 'latin1'"); [enter] >> >> ERROR 1064 (42000): Fehler in der SQL-Syntax. Bitte die korrekte >> Syntax im Handbuch nachschlagen bei 'mysql_query("SET NAMES >> 'latin1'")' in Zeile 1 >> mysql> >> >> How can I change the connection permamently for php? Is it possible? >> Without changing the scripts... >> > > No, mysql_query() is a PHP function call, not a MySQL statement. What > you need is just > > mysql>SET NAMES 'latin1'; > > The easiest way to change startup values is to go into MySQL > Administrator, go to Service Control and click on the Configure Service > tab. Then set the Localization section to the charset you wish. > I have added this call to my php script. It didn't work! I use MySQL on Linux! So there is no Service Control... I don't understand it, the MySQL docs say the standard install comes with latin1... But it seems to be not a rule... Maybe I should recompile MySQL?! Thanks a lot for Your hints! |
|
|
|
#30 |
|
Messages: n/a
Hébergeur: |
Greetings, Marc.
In reply to Your message dated Tuesday, June 10, 2008, 01:45:36, >>>>>> You have the answer, but apparently lost it in your explanation. I'll quote: >>>>>> >>>>>>> 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. >>>>>> You must tell to server, what encoding you want, every time you connecting to >>>>>> database. >>>>>> Just add execution of 'SET NAMES latin1 COLLATE whatever_collation_you_need' >>>>>> statement right after the moment you have connected to database in your script. >>>>> thanks a lot for this advice. But it's not possible to change the whole >>>>> project for this. That's why I would like to set it generally up. On the >>>>> other side, I don't need any other encoding. >>>> You lost the point. >>>> It is not "changing the whole project", it is the action that project must do >>>> once in only one script - one that establishing connection to database. >>>> It is, literally, one line of code to add to whole your project, and it will >>>> serve you to the end of times. >> >>> that seems that easy, but it cannot be the cleanest way. I don't feel so >>> comfortable about it. It has worked already. I just would like to set >>> everything right up. >> >> It has worked already just because server was configured to work that way. >> It was a 4.0 server most likely, or server config have had an init_connect >> option set. Your argument "it was worked already" pointless, because >> environment have changed. >> >> You have only two ways to solve your problem. >> 1. I think it is right way. >> Adapt environment for your needs (by changing connection encoding every time >> you connect to database, it is one line of code in one single file, or in few >> files, if you are not using some sort of abstraction layer) - it will work as >> long as you are using MySQL servers for your database. They may have any >> settings on their own, but you'll have what you need in your script all the >> time. >> >> 2. Hard and one that I not considering acceptable for myself. >> Change your scripts to handle current database output encoding. It will strike >> just about every line of your code, in simple words - it will require to >> rewrite about half of your project. >> >>> I'm sending the data from some external DB by one php script and I'm >>> trying to add this simple line to it... It's gonna take some time, I to >>> new on this stuff. I'm gonna report. >> >> It's simple as find-replace ![]() >> Locate the point in your (key word - your) script, where you are using >> mysql_connect(). >> Add >> mysql_query('SET NAMES latin1'); >> Right after calling mysql_connect(). >> >> It should work. >> >> If you are using some sort of abstraction layer, it may be a bit different, >> but not harder. >> > Adding mysql_query didn't work, I mean it didn't change anything. The > Umlauts are still wrong. You're stating your troubles without any confirmation. Please show us few lines of your code where you have changed it, and explain, how are you tested that it "didn't change anything". I think you have checked it with your other script, which have not been changed, thus not showing you what you want. > I'm really fed up. It makes me sick. I have feeling of your anger, but that's not what makes man wise. -- Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru> |
|
|
|
#31 |
|
Messages: n/a
Hébergeur: |
Marc wrote:
> Jerry Stuckle schrieb: >> Marc wrote: >>> Jerry Stuckle schrieb: >>>> Marc wrote: >>>>> 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 >>>>> >>>> >>>> This statement is connection specific. You need to call it after >>>> connecting, and every time after connecting. Calling it from the >>>> command line only sets it for that connection; it won't set it for >>>> your PHP script, since it uses a different connection. >>>> >>>> But your error message by itself is meaningless. What is the >>>> statement you're entering, and what is the entire error message you >>>> get? It works fine for me. >>>> >>> >>> >>> I have connected with my server via putty, have logged in. Then >>> logged in into mysql: >>> >>> # mysql --password=mypassword --user=myuser [enter] >>> >>> Welcome to the MySQL monitor. Commands end with ; or \g. >>> Your MySQL connection id is 246 >>> Server version: 5.0.32-Debian_7etch5-log Debian etch distribution >>> >>> Type ';' or '\h' for . Type '\c' to clear the buffer. >>> >>> mysql> mysql_query("SET NAMES 'latin1'"); [enter] >>> >>> ERROR 1064 (42000): Fehler in der SQL-Syntax. Bitte die korrekte >>> Syntax im Handbuch nachschlagen bei 'mysql_query("SET NAMES >>> 'latin1'")' in Zeile 1 >>> mysql> >>> >>> How can I change the connection permamently for php? Is it possible? >>> Without changing the scripts... >>> >> >> No, mysql_query() is a PHP function call, not a MySQL statement. What >> you need is just >> >> mysql>SET NAMES 'latin1'; >> >> The easiest way to change startup values is to go into MySQL >> Administrator, go to Service Control and click on the Configure >> Service tab. Then set the Localization section to the charset you wish. >> > > I have added this call to my php script. It didn't work! > > I use MySQL on Linux! So there is no Service Control... > > I don't understand it, the MySQL docs say the standard install comes > with latin1... But it seems to be not a rule... > > Maybe I should recompile MySQL?! > > Thanks a lot for Your hints! > Marc, Since you changed servers, the other possibility is the charset the web page itself is sent as. What is the character encoding your web server is sending for the page? -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#32 |
|
Messages: n/a
Hébergeur: |
Jerry Stuckle schrieb:
> Marc wrote: >> Jerry Stuckle schrieb: >>> Marc wrote: >>>> Jerry Stuckle schrieb: >>>>> Marc wrote: >>>>>> 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 >>>>>> >>>>> >>>>> This statement is connection specific. You need to call it after >>>>> connecting, and every time after connecting. Calling it from the >>>>> command line only sets it for that connection; it won't set it for >>>>> your PHP script, since it uses a different connection. >>>>> >>>>> But your error message by itself is meaningless. What is the >>>>> statement you're entering, and what is the entire error message you >>>>> get? It works fine for me. >>>>> >>>> >>>> >>>> I have connected with my server via putty, have logged in. Then >>>> logged in into mysql: >>>> >>>> # mysql --password=mypassword --user=myuser [enter] >>>> >>>> Welcome to the MySQL monitor. Commands end with ; or \g. >>>> Your MySQL connection id is 246 >>>> Server version: 5.0.32-Debian_7etch5-log Debian etch distribution >>>> >>>> Type ';' or '\h' for . Type '\c' to clear the buffer. >>>> >>>> mysql> mysql_query("SET NAMES 'latin1'"); [enter] >>>> >>>> ERROR 1064 (42000): Fehler in der SQL-Syntax. Bitte die korrekte >>>> Syntax im Handbuch nachschlagen bei 'mysql_query("SET NAMES >>>> 'latin1'")' in Zeile 1 >>>> mysql> >>>> >>>> How can I change the connection permamently for php? Is it possible? >>>> Without changing the scripts... >>>> >>> >>> No, mysql_query() is a PHP function call, not a MySQL statement. >>> What you need is just >>> >>> mysql>SET NAMES 'latin1'; >>> >>> The easiest way to change startup values is to go into MySQL >>> Administrator, go to Service Control and click on the Configure >>> Service tab. Then set the Localization section to the charset you wish. >>> >> >> I have added this call to my php script. It didn't work! >> >> I use MySQL on Linux! So there is no Service Control... >> >> I don't understand it, the MySQL docs say the standard install comes >> with latin1... But it seems to be not a rule... >> >> Maybe I should recompile MySQL?! >> >> Thanks a lot for Your hints! >> > > Marc, > > Since you changed servers, the other possibility is the charset the web > page itself is sent as. What is the character encoding your web server > is sending for the page? > At the beginning there was file 'charset' with AddDefaultCharset UTF-8 at my apache2 config dir. So I didn't get it I have this problem. But then I mentioned umlaut problems at the admin backend, so I've begun to look for the source of it. After deleting this file, I have find out, that DB data won't be shown correctly. The HTML pages have a HEADER with ISO-8859-15. I have set a new 'charset' with ISO encoding - no result. |
|
|
|
#33 |
|
Messages: n/a
Hébergeur: |
Marc wrote:
> Jerry Stuckle schrieb: >> Marc wrote: >>> Jerry Stuckle schrieb: >>>> Marc wrote: >>>>> Jerry Stuckle schrieb: >>>>>> Marc wrote: >>>>>>> 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 >>>>>>> >>>>>> >>>>>> This statement is connection specific. You need to call it after >>>>>> connecting, and every time after connecting. Calling it from the >>>>>> command line only sets it for that connection; it won't set it for >>>>>> your PHP script, since it uses a different connection. >>>>>> >>>>>> But your error message by itself is meaningless. What is the >>>>>> statement you're entering, and what is the entire error message >>>>>> you get? It works fine for me. >>>>>> >>>>> >>>>> >>>>> I have connected with my server via putty, have logged in. Then >>>>> logged in into mysql: >>>>> >>>>> # mysql --password=mypassword --user=myuser [enter] >>>>> >>>>> Welcome to the MySQL monitor. Commands end with ; or \g. >>>>> Your MySQL connection id is 246 >>>>> Server version: 5.0.32-Debian_7etch5-log Debian etch distribution >>>>> >>>>> Type ';' or '\h' for . Type '\c' to clear the buffer. >>>>> >>>>> mysql> mysql_query("SET NAMES 'latin1'"); [enter] >>>>> >>>>> ERROR 1064 (42000): Fehler in der SQL-Syntax. Bitte die korrekte >>>>> Syntax im Handbuch nachschlagen bei 'mysql_query("SET NAMES >>>>> 'latin1'")' in Zeile 1 >>>>> mysql> >>>>> >>>>> How can I change the connection permamently for php? Is it >>>>> possible? Without changing the scripts... >>>>> >>>> >>>> No, mysql_query() is a PHP function call, not a MySQL statement. >>>> What you need is just >>>> >>>> mysql>SET NAMES 'latin1'; >>>> >>>> The easiest way to change startup values is to go into MySQL >>>> Administrator, go to Service Control and click on the Configure >>>> Service tab. Then set the Localization section to the charset you >>>> wish. >>>> >>> >>> I have added this call to my php script. It didn't work! >>> >>> I use MySQL on Linux! So there is no Service Control... >>> >>> I don't understand it, the MySQL docs say the standard install comes >>> with latin1... But it seems to be not a rule... >>> >>> Maybe I should recompile MySQL?! >>> >>> Thanks a lot for Your hints! >>> >> >> Marc, >> >> Since you changed servers, the other possibility is the charset the >> web page itself is sent as. What is the character encoding your web >> server is sending for the page? >> > > > At the beginning there was file 'charset' with AddDefaultCharset UTF-8 > at my apache2 config dir. So I didn't get it I have this problem. But > then I mentioned umlaut problems at the admin backend, so I've begun to > look for the source of it. After deleting this file, I have find out, > that DB data won't be shown correctly. > > The HTML pages have a HEADER with ISO-8859-15. > > I have set a new 'charset' with ISO encoding - no result. > OK, let's back up a bit. What was the charset you used on the previous system? Was it actually latin1? Or could it have been something else? Also, how did you move your data from one system to another? Finally - to set the charset permanently, put it in your my.cfg file under the [mysqld] section, i.e. character_set_client = latin1 -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#34 |
|
Messages: n/a
Hébergeur: |
AnrDaemon schrieb: > Greetings, Marc. > In reply to Your message dated Tuesday, June 10, 2008, 01:45:36, > >>>>>>> You have the answer, but apparently lost it in your explanation. I'll quote: >>>>>>> >>>>>>>> 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. >>>>>>> You must tell to server, what encoding you want, every time you connecting to >>>>>>> database. >>>>>>> Just add execution of 'SET NAMES latin1 COLLATE whatever_collation_you_need' >>>>>>> statement right after the moment you have connected to database in your script. >>>>>> thanks a lot for this advice. But it's not possible to change the whole >>>>>> project for this. That's why I would like to set it generally up. On the >>>>>> other side, I don't need any other encoding. >>>>> You lost the point. >>>>> It is not "changing the whole project", it is the action that project must do >>>>> once in only one script - one that establishing connection to database. >>>>> It is, literally, one line of code to add to whole your project, and it will >>>>> serve you to the end of times. >>>> that seems that easy, but it cannot be the cleanest way. I don't feel so >>>> comfortable about it. It has worked already. I just would like to set >>>> everything right up. >>> It has worked already just because server was configured to work that way. >>> It was a 4.0 server most likely, or server config have had an init_connect >>> option set. Your argument "it was worked already" pointless, because >>> environment have changed. >>> >>> You have only two ways to solve your problem. >>> 1. I think it is right way. >>> Adapt environment for your needs (by changing connection encoding every time >>> you connect to database, it is one line of code in one single file, or in few >>> files, if you are not using some sort of abstraction layer) - it will work as >>> long as you are using MySQL servers for your database. They may have any >>> settings on their own, but you'll have what you need in your script all the >>> time. >>> >>> 2. Hard and one that I not considering acceptable for myself. >>> Change your scripts to handle current database output encoding. It will strike >>> just about every line of your code, in simple words - it will require to >>> rewrite about half of your project. >>> >>>> I'm sending the data from some external DB by one php script and I'm >>>> trying to add this simple line to it... It's gonna take some time, I to >>>> new on this stuff. I'm gonna report. >>> It's simple as find-replace ![]() >>> Locate the point in your (key word - your) script, where you are using >>> mysql_connect(). >>> Add >>> mysql_query('SET NAMES latin1'); >>> Right after calling mysql_connect(). >>> >>> It should work. >>> >>> If you are using some sort of abstraction layer, it may be a bit different, >>> but not harder. >>> > > >> Adding mysql_query didn't work, I mean it didn't change anything. The >> Umlauts are still wrong. > > You're stating your troubles without any confirmation. > Please show us few lines of your code where you have changed it, and explain, > how are you tested that it "didn't change anything". > > I think you have checked it with your other script, which have not been > changed, thus not showing you what you want. > >> I'm really fed up. It makes me sick. > > I have feeling of your anger, but that's not what makes man wise. > > I'm really sorry for giving my angery. I use xt commerce. There are only 2 files calling mysql_connect(). So I have done what You have told, I have three times added mysql_query... 1st: mysql_query('SET NAMES latin1'); 2nd: mysql_query('SET NAMES latin1',@link); 3rd: mysql_query('SET NAMES latin1',@@link); I'm attaching the original files. So I have done it like this: O R I G I N A L: function xtc_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } if ($$link) mysql_select_db($database); return $$link; } C H A N G E D: function xtc_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); mysql_query('SET NAMES latin1'); } if ($$link) mysql_select_db($database); return $$link; } My can reach my site at: http://www.multitasking-berlin.de Going on any product you can't see the umlauts, but switching the browser to UTF-8 you can. The point is, I don't need that much the data, I have it offline and can upload it any time, but uploading works only via PHP and this way causes the umlauts problem... ********************* 1st file in original: ********************* <?php // include(DIR_WS_CLASSES.'/adodb/adodb.inc.php'); function xtc_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } if ($$link) mysql_select_db($database); return $$link; } ?> ********************* 2nd file in original: ********************* <?php defined( '_VALID_XTC' ) or die( 'Direct Access to this location is not allowed.' ); function xtc_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $$link = mysql_pconnect($server, $username, $password); } else { $$link = mysql_connect($server, $username, $password); } if ($$link) mysql_select_db($database); return $$link; } // db connection for Servicedatabase function service_xtc_db_connect($server_service = SERVICE_DB_SERVER, $username_service = SERVICE_DB_SERVER_USERNAME, $password_service = SERVICE_DB_SER |