Beer Temp to Database

This is the source to add the beer temp to my MySQL database.

 



$conn = mysql_connect(“192.168.1.5″, “beerfridge”, “password”) or die(“It doesn’t connect!”);
mysql_select_db(“beerfridge”, $conn) or die(mysql_errno() . “: ” . mysql_error() . “”);

$lines = file(‘/home/restill/sensor/tslpy/tsl.1′);

foreach ($lines as $line_num => $line) {
$line = substr($line,0,5);
$sql=”INSERT INTO tTemps(fTemp) VALUES($line)”;
mysql_query($sql,$conn);
}
mysql_query($sql,$conn);


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>