Switching from stock Debian Squeeze php 5.3.x to dotdeb’s 5.3.10 ’caused encoding problems

I switched from stock Debian Squeeze php 5.3.x to dotdeb’s 5.3.10 yesterday on a lot of servers. Usually a minor upgrade shouldn’t introduce any major changes, but in this particular case I’ve come across several customers having encoding problems. It’s related to the mysql backend, which defaults to utf-8 and customers having code encoded in latin1 (iso8859-1 or iso8859-15), that is: they’ve encoded their stuff in mysql in latin1. It’s an easy fix, you simply have to specify your mysql encoding when connecting via php, f.example:

$link1 = mysql_connect('localhost','user1','pass1',TRUE); 
mysql_selectdb('db1',$link1); 
mysql_set_charset('latin1',$link1); 

More info at php.net

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.