Press "Enter" to skip to content

Category: Snippet

Snippet: PHP, MySQL and IDN Email addresses

Here’s something to look out for if you are building an international website where you are handling email addresses…

Email addresses, as you are probably aware, comprise of two parts. The “local part” (the bit before the @ sign) and the “domain part” (the bit after the @ sign). Therefore with the email address richard@example.invalid , “richard” is the local part and “example.invalid” is the domain part.

The domain part of the email address can actually be 255 characters in length theoretically (it’s 63 characters for the actually domain name, then the TLD: however, you could have sub domains in force which can take it up to the 255 limit.

The local part of the email address can be 64 characters: bringing the count up to 319 characters. Allow an extra one for the “@” sign and 320… Just slightly too big to fit within the standard 255/256 character string field that has tended to be used. I’ve seen rumours that this section may be expanded to 128 characters, so plan for 383 characters.

Oh – don’t forget that Internationalised/Internationalized Domain Names are becoming popular in some countries and unless you want to handle conversion to/from Punycode or another storage format for the IDNs, then you’ll need to make your database store the email address in Unicode… However, that appears to cause a problem in some version of MySQL if you store it all in a Varchar field.

So in your programming language (such as PHP), you’re going to have to keep all the above in mind and then split the email address into two parts for storing in the database for sanity.

See http://www.faqs.org/rfcs/rfc2821.html, http://en.wikipedia.org/wiki/E-mail_address, http://www.santosj.name/general/stop-doing-email-validation-the-wrong-way/ and http://askville.amazon.com/maximum-length-allowed-email-address/AnswerViewer.do?requestId=1166932.

Snippet: How To Tell if Your Cat Is Plotting to Kill You

Let’s face it cat owners, we all know the little fur balls are plotting on taking over the world (I blame the Egyptians myself!). When they aren’t asking “I Can has Cheezburger?, they are working out how to get rid of us humans. Lucikly, there’s a list you can work down to try and work out if the cute little ball of fluff is trying to kill you. There’s even a quiz for you to check – odds are that your cat is trying to kill you.

Snippet: HSBC Overdraft rates for business customers

I’m just looking at a temporary overdraft with my HSBC Business Bank Account and I’m shocked at their fees. For a £2,000 overdraft facility (i.e. just for it to “be there” and not necessarily be used) – they are going to charge me £100 (that’s 5%) setup fee and if I do happen to use it, they’ll charge 10% interest (5.50% over base rate of 4.5%) pa on a monthly basis.

Ok, that’s for a 12 month overdraft – I did just want £1,000 for a month (31 days) just to cover the difference in having to pay for things to sell and getting the money for the items from Paypal (they’ve sold, but it takes 5 workings days to get the funds from Paypal). For a £1,000 overdraft for 31 days, it’ll still cost £20.00 (just 2% this time), but still the 10% interest rate!

Ouch!

Snippet: Yahoo YUI Datatable and Internet Explorer (IE)

I must remember that if I’ve using the Yahoo! (Yahoo User Interface) Datatable and the page validates and works in Firefox, but doesn’t work in Internet Explorer (IE), then the problem is most likely caused by an additional comma at the end of an array.

The YUI logger will not record any actions from that point on and no error will be reported by Microsoft Internet Explorer (at least not IE 6 or IE 7) – it’ll just stop the Javascript from working from the stray comma onwards.

Annoying!