Script to update website

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

$sql = “SELECT date_format(dDate,’%T %c/%e/%Y’) AS dDate,fTemp FROM `tTemps` ORDER BY `tTemps`.`dDate` DESC LIMIT 0 , 30”;

$result = mysql_query($sql,$conn);

$f = fopen(“/home/restill/beerfridge/beertemps.txt”, “w”);

while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
//print “At ” . $row[‘dDate’] . ” the beer fridge is ” . $row[‘fTemp’] . ” degrees Fahrenheit.\n”;
fwrite($f, “At ” . $row[‘dDate’] . ” the beer fridge is ” . number_format($row[‘fTemp’],3) . ” degrees Fahrenheit.\n”);
}

exec(“ncftpput -u richesti -p password -V ftp.richestill.com /public_html/ /home/restill/beerfridge/beertemps.txt”);

fclose($f);

Leave a Reply

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