27th February 09:40
Strange problem between PHP and MySQL
This week-end, I had a strange problem. I had to recompile my PHP
versions (PHP 4.4.4 and PHP 5.1.6) to add XSLT support.
For the compilation, I did nothing special:
--with-dbase --with-filepro --with-xml --enable-exif --enable-ftp
--with-db --enable-bcmath --enable-calendar --with-gd
--enable-gd-native-ttf --with-freetype-dir --with-gettext
--with-zlib-dir --enable-trans-sid --with-imap --with-kerberos
--with-imap-ssl --with-openssl --enable-sysvsem --enable-sysvshm
--with-dom --with-mcrypt --with-iconv --enable-mbstring=all
--enable-mbregex --with-png-dir=/usr --with-jpeg-dir=/usr
--with-ldap --enable-cgi --with-dom-xslt --with-dom-exslt
Before this recompilation, the charset used for transactions between PHP
and MySQL was latin1, after the recompilation of PHP, it is utf8.
I let image what happened on my web sites...
I didn't find anything on the web to correct this problem.
- I changed default_charset to "iso-8859-1" in php.ini: didn't work
- I added in my.cnf (MySQL config file)
- After all, I had in my.cnf
init-connect='SET NAMES latin1'
It works, but I don't like this, for each new connect it changes the
charset. Usally we don't have to do that!!!
Does anybody has an idea to have a clean solution?