compile error: 'connectedOn' was not declared in this scope

Hi There
I am not really experienced at Arduino mega 2560 and I had the following problem.
I have declare int globally " int connectedON and int connectedOFF " and i called these variable from GAE(String link) funtion. I got problem with compiling the code " error: 'connectedOn' was not declared in this scope". I would be grateful if any one can help me.

/*
Iowa Aquaponics: Water Quality DAQ v1.

Monitor: Water temperature, pH and dissolved oxygen.

Credit: Iowa Aquaponics, Hacktronics
*/

#include <SPI.h>
#include <Ethernet.h> // Ethernet Shield
#include <OneWire.h> // DS18B20
#include <DallasTemperature.h> // DS18B20
#include <DHT.h> // DHT. Credit: Adafruit Industries

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 7

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.iowa-aquaponics.com/arduino/#Water Temperature

DeviceAddress tankTemp = { };

// Ethernet Shield
byte mac[] = {
0x90, 0xA2, 0xDA, 0x0F, 0x12, 0xE9 };

char server[] = "http://www.myapsystem.appspot.com";
EthernetClient client;

// Makes it easy to change app names
String webapp = "http://www.myapsystem.appspot.com";

// DHT-22
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

// ANALOG PINS
int AmbientLDR = A0; // Light Dependent Resistor

int connectedON = 8;
int connectedOFF = 9;

char wtemp_str[10]; // Water Temp String
char ph_str[10];

// Sending DHT data
char temp_str[10]; // Temperature string
char rh_str[10]; // Relative Humidity String

String phsensorstring = ""; // A string to build from the sensor output
String dosensorstring = "";

void setup(){
Serial.begin(38400); // Standard Serial to communicate with the computer
Serial2.begin(38400); // Hardware Serial for pH Probe
Serial3.begin(38400);
delay(5000); // Give the hardware time to "boot up"

phsensorstring.reserve(30); // Reserve space for incoming data
dosensorstring.reserve(30);

// DS18B20
sensors.begin();
sensors.setResolution(tankTemp, 10);

// Start Ethernet
Ethernet.begin(mac);
delay(1000);

// Start DHT
dht.begin();

// Set pin modes
pinMode(connectedON, OUTPUT);
pinMode(connectedOFF, OUTPUT);

Serial.println("Setup Complete.");
}

void loop(){
sync();
delay(1800000);
}

String getDHT() {
float h = dht.readHumidity();
float t = dht.readTemperature();

if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
float ftemp = (((9.0/5.0) * t) + 32.0);
String temp = dtostrf(ftemp, 3, 1, temp_str);
String rh = dtostrf(h, 3, 1, rh_str);

String dhtUrl = "&Temp=" + temp + "&Humidity=" + rh;
return(dhtUrl);
}
}

String getLDR() {
int ambientLDR = analogRead(AmbientLDR);
String lightUrl = "&AmbientLDR=" + String(ambientLDR);

return(lightUrl);
}

String getTankTemp(DeviceAddress deviceAddress) {
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
} else {
float wtemp = DallasTemperature::toFahrenheit(tempC); // Convert Celsius to Fahrenheit. To keep Celsius, comment this line out
String water_temp = dtostrf(wtemp, 3, 1, wtemp_str); // and change "wtemp" here to "tempC"
return("?Temp=" + water_temp);
}
}

String getPH() {
char phchar;
while (phchar != '\r') {
phchar = (char)Serial2.read();
if (phchar != '\r') {
phsensorstring += phchar;
}
}

String ph_reading = "";
ph_reading.concat("&pH=" + phsensorstring);
//Serial.println(ph_reading);
phsensorstring = "";
return(ph_reading);
}

String getDO() {
char dochar;
while (dochar != '\r') {
dochar = (char)Serial3.read();
if (dochar != '\r') {
dosensorstring += dochar;
}
}

String do_reading = "";
do_reading.concat("&DO=" + dosensorstring);
//Serial.println(do_reading);
dosensorstring = "";
return(do_reading);
}

void sync() {

// Get Temperature and Humidity
String DHTSensor = "";
DHTSensor = getDHT();
Serial.println("DHT: " + DHTSensor);

// Get LDR Reading
String LDR = "";
LDR = getLDR();
Serial.println("LDR: " + LDR);

// Water Temperature
sensors.requestTemperatures();
String WaterTemp = "";
WaterTemp = getTankTemp(tankTemp);
Serial.println(WaterTemp);

// PH
String PHSensor = "";
PHSensor = getPH();
Serial.println(PHSensor);

// DO
String DOSensor = "";
DOSensor = getDO();
Serial.println(DOSensor);

GAE(webapp + "/adacs/arduino/" + DHTSensor + LDR + WaterTemp + PHSensor + DOSensor);

}

void GAE(String link) {
boolean success = httpRequest(link);
if (success == true) {
delay(5000);

boolean currentLineIsBlank = true;

String readString = "";
char newString[100];

while (client.connected()) {
if (client.available()) {
char c = client.read();
//Serial.write(c);

if (c == '\n' && currentLineIsBlank) {
//Serial.println("Reached end of request");
while(client.connected()) {
char f = client.read();
readString += f;
}
}

if (c == '\n') {
currentLineIsBlank = true;
} else if (c != '\r') {
currentLineIsBlank = false;
}
}
}

client.stop();

Serial.println(readString);
} else {
Serial.println("Not connected.");
boolean success = httpRequest(link);
}
}

boolean httpRequest(String link) {
// if there is a successful connection
if (client.connect(server, 80)) {
Serial.println("GET " + link + " HTTP/1.0"); // For dev mode
client.println("GET " + link + " HTTP/1.0");
client.println();

// Turn connected LED on
digitalWrite(connectedOff, LOW);
digitalWrite(connectedOn, HIGH);

return true;
} else {
// You couldn't make the connection
Serial.println("Connection Failed");
//errors += 1;
client.stop();

// Turn connected LED on
digitalWrite(connectedOn, LOW);
digitalWrite(connectedOff, HIGH);

return false;
}
}

First of all read the sticky thread at the top of the programming questions forum.

Second, use code tags.

Third:

digitalWrite(connectedOn, LOW);

Where do you declare 'connectedOn', I don't see it anywhere, so how is the compiler supposed to compile the above line.

You have however made a global variable called 'connectedON'. Notice the difference? (hint: N != n)

Thank you so much... got it.