not to sure about this (php type conversion is still driving me nuts) - can the cast in line 102 return a non integer e.g. null?
@bantu