TypeError thrown

substr() expects parameter 1 to be string, int given