# problems after moving websites

## br41n

hello,

after i moved some websites from a Gentoo server that didn't get updated for some time (apache 2.0.54, mysql 4.0.24, php 4.3.11) to a new one up2date (php5, mysql5)i noticed some weird problems with them.

When i write a word that contains characters like â ţ Ă etc. everything after that character gets erased.

After some digging i found that it might be some mysql utf8 problem but all my tables have collation utf8_general_ci and after alot of reading and testing i still didn't managed to fix it.

So.. anybody had this problem before or has any ideeas on how to fix this?

Thanks.

----------

## PaulCompton

 *br41n wrote:*   

> hello,
> 
> after i moved some websites from a Gentoo server that didn't get updated for some time (apache 2.0.54, mysql 4.0.24, php 4.3.11) to a new one up2date (php5, mysql5)i noticed some weird problems with them.
> 
> When i write a word that contains characters like â ţ Ă etc. everything after that character gets erased.
> ...

 

PHP5 and MySQL don't talk so well at the moment when it comes to collations. You need to make some changes in /etc/init.d/my.cnf and restart apache and mysql, then it should hopefully be fine:

* everywhere you see default-character-set change it to utf8_general_ci

* make sure that this line is also in the section for [client] (normally near the top of the file)

* in the [mysqld] section you should also have character-set-server=utf8_general_ci as well as default_character_set=utf8_general_ci

Having said this, for our particular database the problem was the other way round, and we had to set all these values to latin1. But I suspect it will work in both directions.

Basically, it seems that PHP5 will only accept one character set for communicating with MySQL, rather than whatever the particular table happens to be. If that is the case, I'm unimpressed. But then, 99% of my apps are on Postgresql for a reason... (oh no, I hope I didn't start a flame war here! I respect MySQL for what it is good for, that just doesn't happen to include the sort of Apps and approach to development that my company is into!)

HTH

Paul

----------

## br41n

hello,

thank your for replying.

i have tried to set characters to utf8_general_ci in my.cnf (they were utf8 ) but when i tried to do mysql restart i got "MySQL NOT started" so i changed back to utf8.

Because mysql didn't want to start with utf8_general_ci i was looking in /usr/share/mysql/charsets and noticed that i didn't had any utf8.xml or anything similar to it. I don't know if that is a problem but im trying to check everything that looks "suspicious".

Again after alot of digging i was thinking i should try latin1 too, it didn't work out at the start cause as i read on some post around here php5 reads utf8 by default and it screwed it up in a different way (weird chars instead of no text  :Smile:  ).

Anyway i added in my.cnf

```
[php-apache2handler]

default-character-set=latin1

```

And it just worked!

The question is now... what if i wanna use another db with utf8? Will php5 cry about it or not?

----------

## PaulCompton

 *br41n wrote:*   

> hello,
> 
> thank your for replying.
> 
> i have tried to set characters to utf8_general_ci in my.cnf (they were utf8 ) but when i tried to do mysql restart i got "MySQL NOT started" so i changed back to utf8.
> ...

 

Ouch - I forgot the php.ini one. Had to do that too. Like I said, we wanted latin1, so it was no problem. It seems that anything else is pretty tricky with current php and mysql. I'm no mysql wizard, simply had to support it for one app on a server I am responsible for and encountered this issue. If it really has to be utf8 in the database, I would try either earlier versions of mysql and php or just use postgres. But then, I would always "just use postgres", and that is probably not a viable solution for you...  :Wink:  Actually, I like Oracle too  :Smile: 

----------

