Working code but throwing an error?

@oneofusis @givemeawhisky , thanks for your response, I pasted the code to the main page away from testing and it seems to work fine with no errors… everything is the same in terms of IDs but only in the testing page it threw this error.