Servo Troubles

I've worked with the Servo library before, but for some reason I can't seem to get my servo to turn.

Here's the code:

      Serial.println("Should be attaching...");
      tempservo.attach(3);
      Serial.print("Writing to: ");Serial.println(temppos);
      tempservo.write(temppos);
      delay(1000);
      Serial.println("To position!");
      tempservo.detach();

Any thoughts...It should be pretty straightforward. The Serial Monitor prints everything and temppos is a valid integer (in one case it was 59), so I can't see why it wouldn't work...

Thanks

Post all of the code, please. Also, post a picture of your setup so we can verify the hardware portion. What you are trying to do is very simple, so you obviously have something fundamental wrong.

It isn't a hardware issue as the same servo attached the same way works fine with different code.

I cannot post some of the code because it has server information on it. Also "gauge" refers to an array of values that will be matched in the for loop.
Here is the majority of the loop code:

  EthernetDHCP.maintain();
  if (client.available()) {
    digitalWrite(GLED, HIGH);
    digitalWrite(RLED, LOW);
    char inChar = client.read();
    if(inChar==','){
      commacount=commacount+1;
    }
    if(commacount==5){
      char dig1= client.read(); 
      char dig2= client.read();
      char dig3= client.read();
      char dig4=client.read();
      char dig5=client.read();
      char dig6=client.read();
      if(dig4=='.'){
        sprintf(tempval, "%c%c%c%c%c%c", dig1,dig2,dig3,dig4,dig5,dig6);
        commacount=6;
      }else if(dig3=='.'){
        sprintf(tempval, "%c%c%c%c%c",dig1,dig2,dig3,dig4,dig5);
        commacount=6;
      }else if(dig2=='.'){
        sprintf(tempval, "%c%c%c%c",dig1,dig2,dig3,dig4);
        commacount=6;
      }
      float tempvalnum=atof(tempval);
      tempvalnum=round(tempvalnum);
      Serial.println(tempvalnum);
      int ii;
      for(ii=0; ii!=89; ii++){
        Serial.println(gauge[ii]);
        if(tempvalnum<5){
          temppos=99;
          break;
        }else if(tempvalnum==gauge[ii]){
          temppos=ii+11;
          Serial.println(temppos);
          break;
        }else if((tempvalnum-1)==gauge[ii]){
          temppos=ii+11;
          Serial.println(temppos);
          break;
        }else if((tempvalnum-2)==gauge[ii]){
          temppos=ii+11;
          break;
        }
      }
      if(temppos>99||temppos<8){
        temppos=11;
      }
      Serial.println("Should be attaching...");
      tempservo.attach(3);
      Serial.print("Writing to: ");Serial.println(temppos);
      tempservo.write(temppos);
      delay(1000);
      Serial.println("To position!");
      tempservo.detach();

Needless to say I do receive an output from my debugging that confirms that it should work:

Should be attaching...
Writing to: 59
To position!

If you have any suggestions I'm open to them. Thanks

So I've narrowed it down to this batch of code being what I think is the problem.

      if(dig4=='.'){
        sprintf(tempval, "%c%c%c%c%c%c", dig1,dig2,dig3,dig4,dig5,dig6);
        commacount=6;
      }else if(dig3=='.'){
        sprintf(tempval, "%c%c%c%c%c",dig1,dig2,dig3,dig4,dig5);
        commacount=6;
      }else if(dig2=='.'){
        sprintf(tempval, "%c%c%c%c",dig1,dig2,dig3,dig4);
        commacount=6;
      }

If I try to write the servo before this code then it works. If I write to the servo after it, it doesn't work. I can't figure out why this would be the case...any ideas? I thought I might be messing up my IF statement by changing the commacount, but I can't make logical sense of that. What am I missing?

No one really seems to be replying to this, but in the meantime I fixed my problem. Can someone explain to me how I fixed my problem...

All I did was change the servo variable name from "tempservo" to "tempservo2" and then it worked.

I used the attached() command to debug it and for some reason it won't attach if the servo name is "tempservo" How does that make any sense?

No one really seems to be replying to this

Perhaps because you never posted the whole code, as requested.