Andrew McCombe


Full Stack Web Developer

MySQL fix: Field ‘xxxx’ doesn’t have a default value

I’ve recently been working on a few of our older websites with newer MySQL installations and am coming across the following error:

SQLSTATE[HY000]: General error: 1364 Field ‘delivery_address_id’ doesn’t have a default value

This is caused by MySQL having a strict mode set which won’t allow INSERT or UPDATE commands with empty fields where the schema doesn’t have a default value set.
There are a couple of fixes for this.


Useful Oh-My-Zsh plugins

Oh-My-Zsh describes itself as a ‘community driven framework for managing your zsh configuration’ and comes with lots of zsh plugins (189 currently) but none are enabled by default. Some zsh plugins are tailored for your specific operating system whilst others are aimed at helping improve developers workflow. Wether you’re using Ruby, Python, PHP or Javascript as your main language or you’re a systems administrator, there will be a plugin to help. Here are the zsh plugins I’m currently using.


How to pear install HTTP2 and HTTP_Request2

Whilst working on a project recently I’ve found the need to install the HTTP2 package from the pear repository. I couldn’t find any useful notes on how to install HTTP2 via pear so here’s my notes on how to pear install HTTP2.


Using different PHP versions on OSX with Apache and Homebrew

By default Apple’s OSX (Mavericks) comes with PHP 5.4 installed but if you want to work on a different version you’re pretty stuck.

My solution to this is to use homebrew to install PHP5.3, 5.4, 5.5 and 5.6 and then simply change the PHP module loaded by apache. Here how to do it.


Sample xdebug.ini file

I use Xdebug when working on PHP websites and often have to manually install it before starting and debugging. I usually find myself searching the internet for a sample xdebug.ini file to use after installing. So here’s a sample xdebug.ini file for my future self (and anyone else it may help).


How to forward a domain to a Vagrant VM with Apache on OSX

I do a lot of my development work using Virtual Machines and Vagrant. This provides an easy way for me to get a working environment up and running locally on the many projects I work on daily. However, one of the problems with this is that these VMs aren’t accessible externally. This can be a problem when you need to show your work or use a third party service that needs access to the site. Here’s how to forward a domain to a Vagrant VM using Apache’s mod_proxy.


Scriptaculous Ajax Autocomplete callback example

Recently, whilst working on an old website at work, I found a need to add additional parameters to a Script.aculo.us Ajax.autocomplete call The documentation show that this is possible via the callback function but unfortunately there isn’t an example provided.


Regular Expression Reference

I’m forever needing a regular expressions (regex) and never note them down anywhere so I’ve decided to put them here so I can reference them later.


Fix for MySQL error Code 1217 – A foreign key constraint fails

If you’re trying to update or drop a table in MySQL and you’re getting the error ‘Error Code: 1217. Cannot delete or update a parent row: a foreign key constraint fails’ you need to toggle the `foreign_key_checks` variable first.


Inspecting jQuery event handlers

Ever had issues finding where a JQuery click handler is defined? Got a project with LOTS of Javascript and can’t find where an event is handled? Here’s how to find out using Google Chrome. 1. Inspect your element. 2. Go to console and enter

Expand the object, right click on the handler: ‘function()’ Select […]