According to the servo.write() reference page
Syntax
servo.write(angle)
Parametersservo: a variable of type Servo
angle: the value to write to the servo, from 0 to 180
Can you see where your code differs from this ? Fix that first then tell us what happens. Try putting some Serial.prints into your program so that you know which sections it is executing and the value of variables at the time