If Intersango didn't want to give BenDavis 511 bitcoins, they would write code that doesn't give it away so freely.
This code was thoroughly tested using testnet.
The issue was with the server configuration, the database user did not have the proper permissions and the code failed in an unexpected way.
I have now changed to relevant code such that any failure of any kind will stop the script cold.
Apparently not thoroughly enough. Test environments are supposed to MATCH the production environment. But of course, secure coding doesn't apply to Bitcoins.