ESP8266: Problems with link query to database

I'm new here and I'm looking forward to your exciting answers!
I was thinking about a problem with the ESP8266 all day today. Unfortunately, I can't figure out my thinking error, maybe you guys can help me there.

I have built a small database, via mySQL and a little php:
With a link that navigates to "TX.php" the 4 variables can be changed. If I want to change cell 1-1 (g1) to 3, I can do this by retrieving from a link of the form:
After that, the content of the database is simply returned shortly.

The ESP8266 should now simply call this link and read the data from the database in the process. My current code is the following: I write it directly to an ESP-01s modul.

#include <ESP8266WiFi.h>

const char* ssid = "WIFI-Name";
const char* password = "pw";

const char* host = "";

void setup()

  Serial.printf("Connecting to %s ", ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  Serial.println(" connected");

void loop()
  WiFiClient client;

  Serial.printf("\n[Connecting to %s ... ", host);
  if (client.connect(host, 80))

    Serial.println("[Sending a request]");
   client.print(String("GET /") +"TX.php?id=10001&pw=87129&g1=2" + " HTTP/1.1\r\n" +
                 "Host: " + host + "\r\n" +
                 "Connection: close\r\n" +
 //   wenn aufgerufnden  wird, wird die Zelle g1 geupdatet. 

    while (client.connected())
      if (client.available())
        String line = client.readStringUntil('\n');
    Serial.println("connection failed!]");

I have also used various other example codes on the internet. However, I have never been able to rewrite the database. I would be very happy if someone can tell me where I might have a problem in the code. Or maybe what I'm trying to do doesn't work at all, I'm not very literate with ESP.

Have a great day!
Thanks in advance,
Greetings from Halle,

Most probably, your nginx server in is forwarding http queries to https. If this is the case, you should use https client in your arduino sketch instead of http.

Perfect! That's it!
I turned off the automatic redirection from HTTP to HTTPs and now everything works, as usual. Thank you :slight_smile:
I think this won't be a security problem if this is only running over http, since it's not sensitive data, right?

Greetings and thanks a lot!

I don't think there will be a security issue since your wifi network is already secure and the exchanged data is not sensitive.

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