Hi guys i am testing the code ive got from youtube which is to send the data from arduino to php database. I find it working and it sends data to database but i am confused as on why the php code named data.php said that: when i try to open it in localhost. Please help me and give me guidance thanks.
Warning : Undefined array key "temperature" in C:\xampp\htdocs\ethernet\data.php on line 20
Here is the php code:
<?php
class dht11{
public $link='';
function __construct($temperature, $humidity){
$this->connect();
$this->storeInDB($temperature, $humidity);
}
function connect(){
$this->link = mysqli_connect('localhost','root','') or die('Cannot connect to the DB');
mysqli_select_db($this->link,'temphumidnew') 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']);
}
?>