UKHeliBob:
A syntax error involves getting the structure of a command wrong as inpinMode(aPin);Note the missing second parameter
orSerial.print("Hello World);Note the missing closing quotes
Your error did not cause a compiler error because what you wrote was syntactically correct code. The compiler had no way of knowing that you had used the wrong variable in the comparison.
Thanks!