What m i missing

if (client.connected())
    {
      Serial.println("connected");
      client.println(str);
      client.println("Host:192.168.11.1");
      client.println();
      client.stop();

      ch1.wh = 0;                                                 //reset wh
       ch2.wh = 0;
     }
    else
    {
     Serial.println("connection failed");
  }
}

if((millis() - previousMillis_temp) > (temp_postrate) )
{
previousMillis_temp=millis();

error: expected unqualified-id before 'if'
Error compiling.

An "a" and a "I" and the rest of your code.

Mark

aryan_htd:
error: expected unqualified-id before 'if'

So the error is before the if and you didn't post that part so we cannot help you.

retry by posting the complete code (see the posting guidelines)

aryan_htd:

if (client.connected())

{
      Serial.println("connected");
      client.println(str);
      client.println("Host:192.168.11.1");
      client.println();
      client.stop();

ch1.wh = 0;                                                //reset wh
      ch2.wh = 0;
    }
    else
    {
    Serial.println("connection failed");
  }
}

if((millis() - previousMillis_temp) > (temp_postrate) )
{
previousMillis_temp=millis();




error: expected unqualified-id before 'if'
Error compiling.

My "best guess" given the minimal amount of code that you supplied ...

if (client.connected())
    {
      Serial.println("connected");
      client.println(str);
      client.println("Host:192.168.11.1");
      client.println();
      client.stop();

      ch1.wh = 0;                                                 //reset wh
       ch2.wh = 0;
     }
    else
    {
     Serial.println("connection failed");
  }
} < < < POSSIBLY AN EXTRA CURLY BRACE HERE ? ? ? 

if((millis() - previousMillis_temp) > (temp_postrate) )
{
previousMillis_temp=millis();