|
if (!mysql_pconnect("localhost:3306","XXXX","XXXXXXXX")) {
echo "Connection failed! ";
echo mysql_errno().": ".mysql_error()." ";
echo " ";
}
if (!mysql_select_db("temp")) {
echo "Could not connect to 'web' database! ";
echo mysql_errno().": ".mysql_error()." ";
echo " ";
}
if (!($id=mysql_query("select max(time) from temps"))) {
echo "Error with query:";
echo mysql_errno().": ".mysql_error()." ";
echo " ";
}
$last_time=mysql_result($id,0,0);
if (!($id=mysql_query("select date_format(\"$last_time\",\"%h:%i %p\")"))) {
echo "Error with query:";
echo mysql_errno().": ".mysql_error()." ";
echo " ";
}
$local_time=mysql_result($id,0,0)." Pacific";
echo "Last reading at $local_time: ";
if (!($id=mysql_query("select temp0,temp1,temp2 from temps where time=\"$last_time\""))) {
echo "Error with query:";
echo mysql_errno().": ".mysql_error()." ";
echo " ";
}
list($crawlspace,$outside,$office)=mysql_fetch_row($id);
if ($metric==1) {
$crawlspace=round((($crawlspace-32)*500)/9)/100;
$outside=round((($outside-32)*500)/9)/100;
$office=round((($office-32)*500)/9)/100;
if ($outside<0)
echo "Crawlspace: $crawlspace°C | Outside: $outside°C | Office: $office°C\n";
else
echo "Crawlspace: $crawlspace°C | Outside: $outside°C | Office: $office°C\n";
} else {
if ($outside<32)
echo "Crawlspace: $crawlspace°F | Outside: $outside°F | Office: $office°F\n";
else
echo "Crawlspace: $crawlspace°F | Outside: $outside°F | Office: $office°F\n";
}
?>
|