I am working at a project with mySQL and Highcharts. First I have an ESP32 with several, whose measurements get wrote into a database called "MariaDB". This measurements which are in the database I represent in a Highsotck chart.
That works fine so far, but my real problem is that:
I have a data.php file and a main.php file. I'd like to change the string "$sensorid" between those two files. I can send the variable "$sensorid" from the main.php to the with the "SESSION" command. That also works, but I can't use this variable in in the data.php file (but with echo the value is correctly sent).
<?php
SESSION_START();
echo "Die empfangene SensorID lautet" .
$_SESSION["sensorid"] ; //This output is correct :)
date_default_timezone_set('Europe/Berlin');
$con = mysql_connect("IP of database","username","password");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('MyHome', $con);
$result = mysql_query("SELECT * FROM `Messwerte` WHERE SensorID = '$sensorid' "); /*In this part I need the value '$sensorid'!*/
while($row = mysql_fetch_array($result)) {
$datum = $row['DateTime'];
$value = round($row['Messwert'],1);
$uts = strtotime ($datum);
if (date('I', time()))
{
$uts = $uts + 7200;
$x=1;
}
else
{
$uts=$uts+3600;
if($x==1)
{
$uts=$uts-7200;
$x=0;
}
}
$datum=date('l, F j y H:i:s',$uts);
$uts *= 1000; // convert from Unix timestamp to JavaScript time
$dataIN[] = array((float)$uts,(float) $value);
}
echo json_encode($dataIN);
mysql_close($con);
?>
I hope you understand what I mean(Im from Germany, so I am not really good in English) otherwise just ask.