Nested If with an else query

I can for the life of me figure out why this wont compile.
Any help is greatly appreciated

I’d rather have an explanation of where I’ve gone wrong too if anyone is willing.

void CountLinksInChain() {

  if (MagnetSense == HIGH); {
    if (FirstMagnet == LOW); {
      FirstMagnet == HIGH;
      CurrentlyCounting == HIGH;
    else if (FirstMagnet == HIGH);  {
        SecondMagnet == HIGH;
      }
    }
  }

}

== HIGH);Oops

AWOL:
== HIGH);Oops

As you can see on the left I'm new.

Can you expand please? I just cant see it

(deleted)

Warning, next sentence may be stupid

I'm using bytes so I thought I could check them using ==

code has updated as i decided to change the way I was doing it as is now happy, so could anyone explain between the two snippets where I've messed up

void CountLinksInChain() {

  if (FirstMagnet == HIGH); {
       if (Sensor1Last != Sensor1State) {
         if (Sensor1State == HIGH); {
          SecondMagnet == HIGH;
         }
      } 
       else { 
         if (FirstMagnet == HIGH);  
             SecondMagnet == HIGH;
    }
  }
}

I think I’ve figured it out.

The else in the first snippet isn’t properly inside the {} of the preceding IF

 if (FirstMagnet == HIGH); {
       if (Sensor1Last != Sensor1State) {
         if (Sensor1State == HIGH); {
          SecondMagnet == HIGH;
         }

What code will be executed if FirstMagnet is HIGH ?
Answer, the semicolon.

What code will be executed whatever the state of FirstMagnet ?
Answer, the rest of the snippet above.

spycatcher2k:
Where in any of the examples, do you see variables set using == , no where!

But that won't cause the code to not compile.
But an else without a previous if will.

SecondMagnet == HIGH;

Is a comparison, not an assignment