Arduino won't send data to MySQL server help please

Hi, I'm trying to send data to a local database on XAMPP using an internet shield but nothing is being displayed in the database. On arduino side it does said it is connected to the server but when it tries to save the data, nothing is saved in the database. Notes that my arduino is not connected to a router but directly to my pc and I set the ip address to be static for the internet shield. Can anyone points out why it is not working?
Here is the link to the project I tried Arduino Sending Sensor Data to MySQL Server (PHPMYADMIN)

Note that my XAMPP is working on the port 80443 and I tried to connect to it in the code but it throws an error each time

Hardware: arduino uno R3, internet shield on the RJ45 port it is written HR911105A

My code:

#include <Ethernet.h>
#include <SPI.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "192.168.1.10";
IPAddress ip(192,168,1,11); 
EthernetClient client;
float latitude = -20.255086;
float longitude = 57.461886;

String message;
int echo1 = 9;
int trigger1 = 4;
int redLed = 7;
int blueLed = 6;
long duration;
long distance;
int pin = 8;
int read1 = 0; // il va stocker la valeur reçu depuis le pin 10


void setup() {
  pinMode(redLed, OUTPUT);
  pinMode(blueLed, OUTPUT);
  pinMode(pin, INPUT);
  pinMode(echo1, INPUT);
  pinMode(trigger1, OUTPUT);
  Serial.begin(9600);
  if (Ethernet.begin(mac) == 0) {
  Serial.println("Failed to configure Ethernet using DHCP");
  Ethernet.begin(mac, ip);
  }
  else{
    Serial.println("Connected");
    }
  delay(1000);
}

void loop() {
  readPin();
  dist();
  
  
}
void dist(){

      digitalWrite(trigger1, LOW);
      delayMicroseconds(2); 
      digitalWrite(trigger1, HIGH);
      delayMicroseconds(10);
      digitalWrite(trigger1, LOW);
      duration = pulseIn(echo1, HIGH);
      distance = (duration/2)*0.034;
      delay(1000);
      readPin();
      lightLed(distance);
      
}

void lightLed(long distance){

while(distance > 19){
    digitalWrite(blueLed, LOW);
    digitalWrite(redLed, LOW);
    digitalWrite(blueLed, HIGH);
    delay(1000);
    digitalWrite(blueLed, LOW);
    digitalWrite(redLed, HIGH);
    delay(1000);
    digitalWrite(redLed, LOW);
    Serial.println("La poubelle est ouverte");
    message="La poubelle est ouverte";
    sending_To_phpmyadmindatabase(message);
    delay(60000);
    dist();
  }
  while(distance >= 14.25 && distance <= 19){
    digitalWrite(blueLed, HIGH);
    digitalWrite(redLed, LOW);
    Serial.println("La poubelle est vide");
    message="La poubelle est vide";
    sending_To_phpmyadmindatabase(message);
    delay(60000);
    dist();
  }
  while(distance >= 9.5 && distance < 14.25){
    digitalWrite(blueLed, LOW);
    digitalWrite(redLed, LOW);
    digitalWrite(blueLed, HIGH);
    delay(1000);
    digitalWrite(blueLed, LOW);
    delay(1000);
    Serial.println("Poubelle rempli à 50%");
    message="Poubelle rempli à 50%";
    sending_To_phpmyadmindatabase(message);
    delay(60000);
    dist();
  }
  while(distance < 9.5){
    digitalWrite(redLed, LOW);
    digitalWrite(blueLed, LOW);
    digitalWrite(redLed, HIGH);
    delay(1000);
    digitalWrite(redLed, LOW);
    delay(1000);
    Serial.println("Poubelle rempli à 75%");
    message="Poubelle rempli à 75%";
    sending_To_phpmyadmindatabase(message);
    delay(60000);
    dist();
  }

}

void readPin(){

  read1 = digitalRead(pin);
  while(read1 == HIGH)
  { 
    Serial.print("\nPoubelle Lourd!");
    read1 = digitalRead(pin);
    if(read1 == LOW)
    {
      break;
    }
    
}
}

void sending_To_phpmyadmindatabase(String message)   //CONNECTING WITH MYSQL
 {
   if (client.connect(server, 80)) {
    Serial.println("connected");
    // Make a HTTP request:
    Serial.print("GET /testcode/dht.php?message=");
    client.print("GET /testcode/dht.php?message=");     //YOUR URL
    Serial.println(message);
    client.print(message);
    client.print("&latitude=");
    Serial.println("&latitude=");
    client.print(latitude);
    Serial.println(latitude);
    client.print("&longitude=");
    Serial.println("&longitude=");
    client.print(longitude);
    Serial.println(longitude);
    client.print(" ");      //SPACE BEFORE HTTP/1.1
    client.print("HTTP/1.1");
    client.println();
    client.println("Host: 192.168.1.10");
    client.println("Connection: close");
    client.println();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }}

My PHP code:

<?php
class dht11{
 public $link='';
 function __construct($message, $latitude, $longitude){
  $this->connect();
  $this->storeInDB($message, $latitude, $longitude);
 }
 
 function connect(){
  $this->link = mysqli_connect('localhost','root','') or die('Cannot connect to the DB');
  mysqli_select_db($this->link,'poubelle_connecter') or die('Cannot select the DB');
 }
 
 function storeInDB($message, $latitude, $longitude){
  $query = "insert into donnee set message='".$message."', latitude='".$latitude."',longitude='".$longitude."'";
  $result = mysqli_query($this->link,$query) or die('Errant query:  '.$query);
 }
 
}

$dht11=new dht11($_GET['message'],$_GET['latitude'], $_GET['longitude']);


?>

I don't think the problem is with the PHP code since I tried inserting data manually from my browser

What do your MySQL logs say?

Hi sorry for replying so late. Where can I checked this pleased?

So the code works fine, the only thing need to be done is allowing port 80 through windows firewall and the connection to the database works as a charm.

Are you sure the SQL server doesn't need a password for the root user?
And by the way, connecting to it with root is not advisable.
You might like to set up a new non-root user (with password) and try that. Then secure the SQL server with a root password :-)!!

I'm just doing a proof of concept. There is no need for security or using PDO statements, etc. I juet need to proof that it is feasible

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