Thank you for your help and the fixed code from JamesNC works fine - I'm not sure I understand all the differences yet but I intend to find out and understand.
A couple of other comments - I had tried printing the $month variable and it displayed ok - I even tried incrementing it's value ($month++) and printing that value and that also worked. The 500 problem arose as soon as I used the if statement and that's what I couldn't understand and at the moment I don't really understand wht the code fix does work but once I have added a couple of other bits to the code I will be coming back to this to try and understand why things happened or not as the case may be.
Thanks again for your shared wisdom it has bee very much appreciated
Julian