PHP hell with a .csv file

I’ve just spent the morning battling with a piece of code that that pulls about 7000 rows from join over 5 tables, does a bit of post processing and then exports it as a .csv file with about 15 columns.

I hunted down all the bugs until everything worked fine, the script would run and the windows alert box would pop up asking if I wanted to save or open the file, so far so good.

But then try and open the file in Excel and bang:

SYLK: File format is not valid

What the hell does this mean? I spent hours tweaking and adjusting, looking at the file in editplus and OpenOffice – looking for some kind of error to do with un-escaped characters… nothing, not a peep.

As a final last ditch attempt, before I pulled all my hair out, I typed the Excel error message into Google… guess what:
“SYLK: File format is not valid” error message when you open file


When you try to open a text file or a comma-separated variable (CSV) file, you may receive the following error message:
SYLK: File format is not valid
Back to the top


This problem occurs when you open a text file or CSV file and the first two characters of the file are the uppercase letters “I” and “D”. For example, the text file may contain the following text:

123, open
456, closed

Note This problem does not occur if the first two letters are lowercase “i” and “d”.

How daft is that.

Compare UK online payment providers

I’m putting together a quick table to compare the online payment processing options available at the moment. At work clients are always asking us to recomend a company or coming to us wanting to use scary providers they found on the internet, and based in places like Nigeria.

There are only so many numbers you can keep track of, so I’ve started putting together a quick reference. This is aimed fair and square at smaller sites where people are dipping their toes into the bright new frontier of e-commerce. I have tried to pick the starter package where possible.

Please contact me with to recommend providers, share your experiences or get me to add companies to this very short list.

Name Cost per month Setup Per Transaction Fee Package Notes
PROTX £20.00 n/a n/a Small Business Service up to 1000 transactions / month
Secure Trading          
WorldPay £30.00 £200.00 Credit Cards 3.75% – 4.5%
Debit Cards £0.38 – £0.50
Small Business
PayPal n/a n/a 3.4% + £0.20 Payment Processing Standard up to £1500 / month
Google Checkout n/a n/a 1.5% + £0.15 per transaction Google Checkout FREE no transaction fees until 2008
SecPay £20.00 n/a £0.20 Premium 20  

Reflections on learning CakePHP

I wrote this as a response to a post on this blog – it has a lot of useful links and it also got me thinking.

I’ve been a full time PHP developer for 3 years now (ASP prior to that) – over the past few months I’ve been learning and writing a couple of sites in Cake.

MVC is quite a different way of working to the way most PHP things seem to have been built (and the way I have built my projects) – but when you persevere and everything falls into place you don’t want to go back.

I find myself constantly checking to see if the work I’ve done so far in Cake is up to the point where I can stop using our current CMS framework at work and move to a Cake based system – unfortunately it isn’t quite there – but it will be soo, and I can’t wait.

Personally the hardest thing I have found is the transition to getting query results as quite complex arrays rather than the simple flat results that you get from mysql_fetch_array.

The one thing that I have found invaluble (when dealing with multi table relationships) as an aid is to simply pr() the variable holding my results array into the view I’m working on so I can see the paths I need to follow to the data I want.