$insertsql="INSERT INTO fac_SensorReadings SET DeviceID=$dev->DeviceID, Temperature=$temp, Humidity=$humidity, LastRead=NOW() ON DUPLICATE KEY UPDATE Temperature=$temp, Humidity=$humidity, LastRead=NOW();";