Arduino Ethernet shield dht11 php + mysql (xampp)

hello,
I am trying to connect my arduino uno + ethernet shield with mysql server. I have sensor dht11 and used php to do that. Can you help me. This is my code:

arduino code:

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

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // RESERVED MAC ADDRESS
EthernetClient client;

#define DHTPIN 2 // SENSOR PIN
#define DHTTYPE DHT11 // SENSOR TYPE - THE ADAFRUIT LIBRARY OFFERS SUPPORT FOR MORE MODELS
DHT dht(DHTPIN, DHTTYPE);

long previousMillis = 0;
unsigned long currentMillis = 0;
long interval = 250000; // READING INTERVAL

int t = 0; // TEMPERATURE VAR
int h = 0; // HUMIDITY VAR
String data;

void setup() {
Serial.begin(115200);

if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
}

dht.begin();
delay(10000); // GIVE THE SENSOR SOME TIME TO START

h = (int) dht.readHumidity();
t = (int) dht.readTemperature();

data = "";
}

void loop(){

currentMillis = millis();
if(currentMillis - previousMillis > interval) { // READ ONLY ONCE PER INTERVAL
previousMillis = currentMillis;
h = (int) dht.readHumidity();
t = (int) dht.readTemperature();
}

data = "temp1=" + t;
data = data + "hum1=" + h;

if (client.connect("192.168.0.108",3306)) { // REPLACE WITH YOUR SERVER ADDRESS
client.println("POST /add.php HTTP/1.1");
client.println("Host: 192.168.0.108"); // SERVER ADDRESS HERE TOO
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
}

if (client.connected()) {
client.stop(); // DISCONNECT FROM THE SERVER
}

delay(300000); // WAIT FIVE MINUTES BEFORE SENDING AGAIN
}

add.php =>

<?php include("connect.php"); $link=Connection(); $temp1=$_POST["temp1"]; $hum1=$_POST["hum1"]; $query = "INSERT INTO `tempLog` (`temperature`, `humidity`) VALUES ('".$temp1."','".$hum1."')"; mysql_query($query,$link); mysql_close($link); header("Location: index.php"); ?>

connect.php =>

<?php function Connection(){ $server="localhost"; $user="root"; $pass="fifa2005"; $db="test"; $connection = mysql_connect($server, $user, $pass); if (!$connection) { die('MySQL ERROR: ' . mysql_error()); } mysql_select_db($db) or die( 'MySQL ERROR: '. mysql_error() ); return $connection; } ?>

index.php =>

<?php include("connect.php"); $link=Connection(); $result=mysql_query("SELECT * FROM `tempLog` ORDER BY `timeStamp` DESC",$link); ?> Sensor Data

Temperature / moisture sensor readings

<?php if($result!==FALSE){ while($row = mysql_fetch_array($result)) { printf("", $row["timeStamp"], $row["temperature"], $row["humidity"]); } mysql_free_result($result); mysql_close(); } ?>
 Timestamp   Temperature 1   Moisture 1 
 %s  %s   %s 

MYSQL=>

data = "temp1=" + t;
data = data + "hum1=" + h;

Not correctly formatted.
You want
temp1=78&hum1=63

in the example that I watched this part was written as follows:
data = "temp1=" + t + "&hum1=" + h;

but then I displayed the following error:

TEST_TEMPRETURE_MYSQL.ino:45:24: error: invalid operands of types 'const char*' and 'const char [7]' to binary 'operator+'
Error compiling.

i add '&' to my code but nothing happend again :frowning:

You can't add values of different types in c++; like String +int won't work. You need to convert types so they match.

First question that occurs to me is why do you want to POST? GET is so much simpler. Both will cause the same script to do almost the same thing.

Second question is why you are pissing away resources using Strings. The same statement could be created using sprintf() and a char array.

The data portion of the POST function needs to end with carriage return/line feed, too.