I've getting data from a MySQL database (gpio temperature sensor) and storing 1 row into a variable to use with pCharts. This is in php
If i create the variable manually this work
$sensor1c = "24.5,24.5,24.5,24.5,24.5,24.5,24.5,24.5,24.5,24.5,24.5,24.5,";
However if i get the data from the DB and then add it to a variable via a while loop it doesn't work.
$order = "SELECT sensor2c FROM (SELECT * FROM temperature ORDER BY id DESC LIMIT 12) sub ORDER BY id ASC;";
$result = mysql_query($order);
while($data = mysql_fetch_row($result))
{
$sensor1c .= $data[0];
$sensor1c .= ",";
}
Does anyone know why the two are different? Also tried with no luck
$sensor1c = (string)$sensor1c;
CONCAT_WS
function of MySql to get the result you want without looping.mysql_query($order) or die(mysql_error());
to ensure there is no error in the query.mysql_query
is procedural code, there is no need for raising an exception in this code here. If there is no data rest can't perform. Let's stick with the scope of the question, not get into a major architecture discussion IMHO