Analysing, reviewing and recording weather patterns in Dayboro since 2004. Challenging the main stream climate change thought, by being objective and providing facts.

<?php
$servername = “localhost”;
$username = “username”;
$password = “password”;
$database = “database”;

//Clean out the results variable
mysqli_free_result($result);
//Close the database connection
mysqli_close($con);

// Create connection
$con = new mysqli($servername, $username, $password, $database);

// Check connection
if($con->connect_errno > 0){
die(‘Unable to connect to database [‘ . $con->connect_error . ‘]’);
}
$sysdate = date(‘Y-m-d G:i:s’);
echo “Connected successfully on “.$sysdate;
echo “<br />”;

//read the json file contents
$jsondata = file_get_contents(‘uradmonitorIPaddress/j’);
echo “done jason data”;
echo “<br />”;

//convert json object to php associative array
$data = json_decode($jsondata, true);

//get the data
$id = $data[‘data’][‘id’];
$type = $data[‘data’][‘type’];
$detector = $data[‘data’][‘detector’];
$cpm = $data[‘data’][‘cpm’];
$voltage = $data[‘data’][‘voltage’];
$temperature = $data[‘data’][‘temperature’];
$humidity = $data[‘data’][‘humidity’];
$pressure = $data[‘data’][‘pressure’];
$voc = $data[‘data’][‘voc’];
$co2 = $data[‘data’][‘co2’];
$noise = $data[‘data’][‘noise’];
$ch2o = $data[‘data’][‘ch2o’];
$pm25 = $data[‘data’][‘pm25’];
$uptime = $data[‘data’][‘uptime’];
$timestamp = date(‘Y-m-d H:i:s’, time());

echo $id;
echo “<br />”;
$hour = date(‘H’);
$minute = date(‘i’);
$year = date(‘Y’);
$month = date(‘m’);
$day = date(‘d’);
echo “split up times”;
echo “<br />”;

//insert into mysql table
$sql = “INSERT INTO `urad`(id, type, detector, cpm, temperature, uptime, timestamp, co2, noise, pm25, year, month, day, hour, minute)
VALUES
(‘$id’, ‘$type’, ‘$detector’, ‘$cpm’, ‘$temperature’, ‘$uptime’, ‘$timestamp’, ‘$co2’, ‘$noise’, ‘$pm25′,’$year’, ‘$month’, ‘$day’, ‘$hour’, ‘$minute’)”;
echo “Start Running Query”;
if(!$result = $con->query($sql)){
die(‘There was an error running the query [‘ . $con->error . ‘]’);
}
echo $sql;
echo “<br />”;
?>