MySQL+DHT11+PHP

Hi
I( am traying to connect my Yun with DHT11 to MYSQL but the values I get from Temeperature and humidity are transfered to MYsql with “0” values even in Screen the values are showed correctly.

If I write this

client.get("http://wi-sen.esy.es/dht11/sensorarduino.php?temperature=t&humidity=h");
The values loaded in MYSQL are “0”
But instead this I write directly a value for temperature and a value for humidity like this
client.get("http://wi-sen.esy.es/dht11/sensorarduino.php?temperature=5&humidity=6");
Then these values are correctly storage in MySQL "5" temperature and HUmidity "6"

This is the code: I will thanks any help!.
#include <Bridge.h>
#include <HttpClient.h>
#include <YunClient.h>
#include <YunServer.h>
#include <DHT.h>

#define DHTPIN 2 // pin de salida
#define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);

void setup() {

Bridge.begin();
Serial.begin(9600);
Serial.println("DHT11 test!");

dht.begin();
while(!Serial);

}
void loop() {
// Initialize the client library
HttpClient client;
int h = dht.readHumidity();
int t = dht.readTemperature();

// Make a HTTP request:
client.get("http://wi-sen.esy.es/dht11/sensorarduino.php?temperature=t&humidity=h");

if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
}
delay(10000);
Serial.flush();
}


Regards
Óscar

The characters 't' and 'h' in your url have nothing to do with variables t and h in your code.

kind regards,

Jos

oscarcuenca2:
// Make a HTTP request:
client.get("http://wi-sen.esy.es/dht11/sensorarduino.php?temperature=t&humidity=h");

As JosAH points out, you are literally sending the values "t" and "h" to the web server (the actual character strings, not the values of the variables in your sketch.)

Rather than one long string, you need some runtime code to combine the actual variable values with the rest of the string, the same kind of idea where you print those values to the a Serial port.

This is one way to do it:

client.get(String("http://wi-sen.esy.es/dht11/sensorarduino.php?temperature=") + t + String("&humidity=") + h);

Hi ShapeShifter
It works perfectly.
I did not know that first I need to change the values to string because it is the way arduino can send data to server.
Thanks and I hope your code can help more people.
Rgds
Oscar