New domain name

Hooray I’ve joined the .nz revolution with my brand-spanking new domain name phpdeveloper.nz

Not only is the redundant .co part gone (good riddance!) but PHP Developer is a better description than PHP Programmer.

Let the good times roll. I really should write something new and interesting…

Email newsletter HTML/CSS rules

I keep forgetting this rules I made for myself, so here they are. Target platforms:
gmail, hotmail, yahoo, outlook 2007, outlook express, iphone mail, android gmail

  • Basically, dont use a stylesheet – do inline styles on divs and spans (trust me – this will reduce your cross-browser issues)
  • Dont use h1, h2, p, etc – just use div and span (other tags have their own styles in yahoo etc)
  • Only use margins, don’t use padding
  • Use margins, but only like this: margin-right, margin-bottom, margin-left
  • So, you need top margin?: use a general padder like this:

    <div style="margin-bottom: 16px;">
    <table cellpadding="0" cellspacing="0"><tr><td></td></tr></table>
    </div>
    
  • Don’t use colour shortcuts like this: #efe. Write it fully, eg: #eeffee
  • Need a solid line?
    <div style="border-top: 1px solid black; font-size: 0px;">&nbsp;</div>
    

    If you have set the line height in a parent div you might want to add

    line-height: 0px

    to the above solid line div. Althought, I’ve found it’s best to avoid line-height altogether (outlook)

  • Fine-print not fine enough in iPhone mail? (ok you’re allowed to use stylesheet now :)
    <style type="text/css">
    div, span { -webkit-text-size-adjust:none; }
    </style> 
    
  • Need to right-align an image? Pop it in a table
    <table cellpadding="0" cellspacing="0" align="right">
      <tr>
        <td>
          <img src="image.jpg" alt="" />
        </td>
      </tr>
    </table>
    
    

If you follow these strict rules you shouldn’t be compaining about Outlook 2007 (lowest common denominator)

UTF-8 setup (again) – for Debian Squeeze

This post is mostly for my own reference – but maybe you will find it useful. Here are my current Linux, Apache, MySQL, PHP settings for supporting UTF-8 properly!

Linux
—–

# dpkg-reconfigure locales

I chose: en_NZ.UTF-8 UTF-8

Apache
——

edit file /etc/apache2/conf.d/charset
uncomment the line:
AddDefaultCharset UTF-8

MySQL
—–

make sure these settings are in /etc/mysql/my.cnf:

[mysqld]
character_set_server=utf8
collation_server=utf8_unicode_ci

[client]
default-character-set=utf8

PHP

make sure these settings are in /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini:

default_charset = utf-8

And in all scripts, when you make the mysql connection, always do this:

mysql_set_charset(‘utf8’);