ESP8266 POST Isn't Updating My Database Anymore

Hello,

I am using an ESP8266 to send HTTP POST data from a temperature and humidity sensor as well as an input for a garage door status to a database where I then use some additional PHP code to display the information on a website. The code I used as a template worked for me at one time when I only displayed the temperature and humidity data, but now that I've added the garage door information I've clearly broken something. When I log into PHPMyAdmin and look at the table, it isn't updating anything - even with these "dummy" values I've created just to ensure I didn't do something wrong elsewhere. However, I do get a successful "POST connection successful" message so I'm making a connection to the database...I just seem to have lost the ability to actually add new rows of updates.

The HTTP POST code is here. It calls add.php which I've quoted below as well.

void httppost () {
  int temp=77;
  int hum=79;
  String strTempdata=String(temp);
  String strHumdata= String(hum);
  String data3 = "temperature=" + strTempdata + " & humidity="+ strHumdata + "& gdostatus=Open";      ; // data sent must be under this form //name1=value1&name2=value2.
  Serial.println("Trying to connect to domain..."); 
  if (client.connect("homewatchiot.net",80)) { // MY SERVER ADDRESS 
    Serial.println("Connected to homewatchiot server on port 80");
    Serial.println("Sending HTTP Post...");
    //POST data
    http.begin("http://homewatchiot.net:80/add.php");              //Specify request destination
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");    //Specify content-type header
    int httpCode = http.POST(data3);   //Send the request
    delay(3000); //Pause to wait for the response
    bPOSTWait=true;
    String payload = http.getString();    //Get the response payload
    if (httpCode ==200)
    {
      Serial.println("POST connection successful");
      bPostSuccess = true;
    }
    else{
      String strFail="POST connection failed - error code ";
      Serial.println(strFail+httpCode);
      bPostSuccess = false;
    }
  }
  else{
    Serial.println("Could not connect to domain.");
    bPostSuccess = false;
  }
 
    bPOSTWait=false;
    http.end();  //Close connection
}

Here's the add.php code:

<?php
   	include("connect.php");
   	
   	$link=Connection();

	$temperature=$_POST["temperature"];
	$humidity=$_POST["humidity"];
	$gdostatus=$_POST["gdostatus"];

	$query = "INSERT INTO `tempLog` (`temperature`, `humidity`,'gdostatus') 
	    VALUES ('".$temperature."','".$humidity."','".$gdostatus."')"; 
   	
   	//mysqli_query($query,$link);
   	mysqli_query($link,$query);
	mysqli_close($link);

   	header("Location: index.php");
?>

Of course, all help is appreciated!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.