Hi,
My database is latin bin ci, my charset of our page is ISO-8859-1 but the chars with accent show such as Sugestões where must appear Sugestões.
We're trying to move host, in our actual host we haven't this problem.
Kind regards,
Marshall
charset issues between mysql and php
-
- New to forums
- Posts: 5
- https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
- Joined: Tue Jan 31, 2012 10:06 am
Re: charset issues between mysql and php
When you import your database, make sure that the character set of the new database matches the old one, and that should prevent this sort of problem. You should be able to change the character set through phpMyAdmin.
-
- New to forums
- Posts: 5
- Joined: Tue Jan 31, 2012 10:06 am
Re: charset issues between mysql and php
First of all, thanks a lot for reply,
I already did this, but my problem persists.
Kind regards,
Marshall
I already did this, but my problem persists.
Kind regards,
Marshall
Re: charset issues between mysql and php
Did you change it after you imported, or before you imported? The character set for the database will need to be set before you populate it with tables -- before you import -- as it determines what each table will use by default.
You will also need to make sure that your application is setting the character set that it wishes to communicate in when it establishes its MySQL connections.
If you don't choose one specifically, a default character set of utf8 will be used. Some hosts use latin1, and it's likely that your exported tables are saved in that format. utf8 is a more universal set and has become the internet standard, making it a better starting point, but you need to continue using whatever you have already been using for the characters to show correctly.
You will also need to make sure that your application is setting the character set that it wishes to communicate in when it establishes its MySQL connections.
If you don't choose one specifically, a default character set of utf8 will be used. Some hosts use latin1, and it's likely that your exported tables are saved in that format. utf8 is a more universal set and has become the internet standard, making it a better starting point, but you need to continue using whatever you have already been using for the characters to show correctly.
-
- New to forums
- Posts: 5
- Joined: Tue Jan 31, 2012 10:06 am
Re: charset issues between mysql and php
I set the collate before run the dump file.
My app is using the same old in my actual host, Today my host stay in Brazil so I guess the php.ini and another stuffs are set to latin.
Where can I change the charset in my app?
I'm php noob.
Thx
My app is using the same old in my actual host, Today my host stay in Brazil so I guess the php.ini and another stuffs are set to latin.
Where can I change the charset in my app?
I'm php noob.
Thx
Re: charset issues between mysql and php
When I say that you need to set the character set on the database, I mean with an SQL command like this:
ALTER DATABASE your_database CHARACTER SET latin1 COLLATE latin1_swedish_ci;
(replacing this with the appropriate character set and collation for your existing data)
.. if it gives you an error when executing this because of permissions, let us know in a support request, and I can try doing it for you.
I don't know where you would set the character set in your specific app (every one is different), so this is something that you would have to try to find by looking in its configuration files and/or documentation. If it's a well-written application, changing the setting will cause it to perform the command "SET NAMES ..." first whenever it connects to the MySQL server.
It is possible that you might also need to use a different workaround that I'm not familiar with. Character sets and collations and converting between them is a rather complicated subject. A Googling turns up many others who have had similar problems to yours, and the general consensus seems to be that switching to udf8 throughout is the best plan in the long run -- but that can be a rather involved process, which is why I was suggesting the workaround of continuing to use your existing set. Before you continue, it would be worth checking out some of the articles out there on character set problems.
ALTER DATABASE your_database CHARACTER SET latin1 COLLATE latin1_swedish_ci;
(replacing this with the appropriate character set and collation for your existing data)
.. if it gives you an error when executing this because of permissions, let us know in a support request, and I can try doing it for you.
I don't know where you would set the character set in your specific app (every one is different), so this is something that you would have to try to find by looking in its configuration files and/or documentation. If it's a well-written application, changing the setting will cause it to perform the command "SET NAMES ..." first whenever it connects to the MySQL server.
It is possible that you might also need to use a different workaround that I'm not familiar with. Character sets and collations and converting between them is a rather complicated subject. A Googling turns up many others who have had similar problems to yours, and the general consensus seems to be that switching to udf8 throughout is the best plan in the long run -- but that can be a rather involved process, which is why I was suggesting the workaround of continuing to use your existing set. Before you continue, it would be worth checking out some of the articles out there on character set problems.