how to prevent switching the connection encoding by reconnect? Everything of my settings are utf-8, but since I have enabled this 开发者_Go百科function in php.ini of the cli ... I have tested anything ... and when I have a long working script then in any point of the script the connection is switched and I have wrong data. After I have disabled it again, then everything is fine. But why is it so? What kind of settings should I set in my.cfg to prevent this switching of the connection encoding?
Cheers Nik
From the MySQL Docs:
If you are using the mysql client with auto-reconnect enabled (which is not recommended), it is preferable to use the charset command rather than SET NAMES. For example:
mysql> charset utf8
Charset changed
The charset command issues a SET NAMES statement, and also changes the default character set that mysql uses when it reconnects after the connection has dropped. Therefore, issue this:
mysqli_query('charset utf8');
Or whatever charset you're using (if other than UTF8). This should fix the problem.
精彩评论