Else if statement

I’m quite new to this and I am trying to use the else if statement but I receive the error “else without a previous if” at the row I made red. Can I get some advice please?

int led1 = 8; // Creating variable for top most led
int led2 = 9; //Creating variable for second top most led
int led3 = 10;
int potentiometer1 = A0; // Potentiometer 1
int photosensor1 = A2;

int potentiometervalue1 = analogRead(potentiometer1);
int photosensorvalue1 = analogRead(photosensor1);
void setup() 
{
 Serial.begin(9600);
 pinMode (led1, OUTPUT); // making I/O into an Output
 pinMode (led2, OUTPUT);
 pinMode (led3, OUTPUT);
}

void loop() 
{
  Serial.println("kokoko");
potentiometervalue1 = analogRead(potentiometer1);
 photosensorvalue1 = analogRead(photosensor1);
 Serial.println(potentiometervalue1);
 Serial.println(photosensorvalue1);
 if (photosensorvalue1 > 700)
 {
    Serial.println("yaayayayaya");
   digitalWrite(led1, LOW);
   digitalWrite(led2, LOW);
   digitalWrite(led3, LOW);
   analogRead(potentiometer1);

 }
 if (potentiometervalue1 < 25 && photosensorvalue1 <700)
 {
   Serial.println(photosensorvalue1);
    Serial.println("Are u in here");
    analogRead(potentiometer1);
     analogRead(photosensor1);
   digitalWrite(led1, HIGH);
   digitalWrite(led2, LOW);
   digitalWrite(led3, LOW);
 }
else if ((potentiometervalue1 <= 500) && (potentiometervalue1 >= 250) && (photosensorvalue1 <700))
 {
    Serial.println("Not here");
   Serial.println(photosensorvalue1);
   analogRead(potentiometer1);
   analogRead(photosensor1);
   digitalWrite(led1, LOW);
   digitalWrite(led2, HIGH);
   digitalWrite(led3, LOW);
   analogRead(potentiometer1);
   analogRead(photosensor1);
 }

 else if (( photosensorvalue1 > 700)   && (potentiometervalue1 > 500));
   {
   Serial.println(photosensorvalue1);
   Serial.println("Over here");
    digitalWrite(led1, HIGH);
   digitalWrite(led2, HIGH);
   digitalWrite(led3, HIGH);
   
 [color=red]else[/color]
 {
   Serial.println(photosensorvalue1);
   Serial.println("yaayayayaya");
   digitalWrite(led1, LOW);
   digitalWrite(led2, LOW);
   digitalWrite(led3, LOW);
   analogRead(potentiometer1);
 }

}

Moderator: Code tags added

    digitalWrite(led3, HIGH);
    
  else
  {

There is no "if" there. Did you mean to put a closing brace } after the digitalWrite? Sort out your {} braces.

(This isn't an installation and troubleshooting sort of question)

To see the problem, use tools -> autoformat in the IDE. You will see that the last } is not at the beginning of a line; this indicates that your are somewhere missing a } (as pointer out by TolpuddleSartre).

Note that the autoformat will not magically fix your code; that you will have to do yourself ;)

Also not the extra semicolon:

 }

 else if (( photosensorvalue1 > 700)   && (potentiometervalue1 > 500));
   {
   Serial.println(photosensorvalue1);
   Serial.println("Over here");

The compiler sees that ‘;’ as a statement:

 }

 else if (( photosensorvalue1 > 700)   && (potentiometervalue1 > 500))
    ;  // Do nothing

  // And then do some unconditional statements:
   {
   Serial.println(photosensorvalue1);
   Serial.println("Over here");