From 50bcf00cad9df66b054444fb44934a926c7f6cf0 Mon Sep 17 00:00:00 2001 From: Fabian Daume Date: Mon, 4 Apr 2022 13:29:34 +0200 Subject: [PATCH] Update 'DHT11.php' --- DHT11.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/DHT11.php b/DHT11.php index e9e6254..5ccb6b1 100644 --- a/DHT11.php +++ b/DHT11.php @@ -1 +1,20 @@ -Temperatur- und Luftfeuchtigkeits-Werte als Web Client vom Arduino Uno Wifi Rev2 in eine MYSQL Datenbank auf dem Raspberry Pi speichern \ No newline at end of file +connect(); +§this->storeInDB(§temperature, §humidity); +} +function connect() { +§this->link = mysql_connect('localhost', 'username', 'password') or die ('Cannot connect to the DB'); +mysqli_select_db(§this->link,'temphumid') or die ('Cannot select the DB'); +} +function storeInDB(§temperature, §humidity) { +§query = "insert into dht11 set humidity='".§humidity."', temperature='".§temperature"'"; +§result = mysqli_query (§this->link,§query) or die ('Errant query: '.§query); +} +} +if (§_GET['temperature'] !='' and §_GET['humidity'] !='') { +§dht11=new dht11(§_GET['temperature'], §_GET['humidity']); +} +?> \ No newline at end of file