As you can clearly see, the IF statements in the 2 top scripts have not been opened with a bracket. Whereas the bottom 2 have been scripted properly.

Syntax is: IF (CONDITION) { DO STUFF }
What you have is: IF (CONDITION)
And nothing else.