Prova con questo, modificando debitamente la funzione file_put_contents a fondo script:
Codice PHP:
<?php
$hostname_conn = "localhost";
$database_conn = "database";
$username_conn = "root";
$password_conn = "password";
$conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);
?>
<?php
// Query the database and get all the records from the Images table
mysql_select_db($database_conn, $conn);
$query_rsImages = "SELECT dataora, idzona, idnegozi, temp FROM datitemperature WHERE idnegozi=2";
$rsImages = mysql_query($query_rsImages, $conn) or die(mysql_error());
$row_rsImages = mysql_fetch_assoc($rsImages);
$totalRows_rsImages = mysql_num_rows($rsImages);
$xml="<?xml version='1.0' encoding='utf-8'?>
<temperature>";
if ($totalRows_rsImages > 0) {
do {
$xml.="
<dati>
<dataora>".$row_rsImages['dataora']."</dataora>
<idzona>".$row_rsImages['idzona']."</idzona>
<idnegozi>".$row_rsImages['idnegozi']."</idnegozi>
<temp>".$row_rsImages['temp']."</temp>
</dati>";
} while ($row_rsImages = mysql_fetch_assoc($rsImages));
}
$xml.="
</temperature>";
mysql_free_result($rsImages);
file_put_contents("scrivi_qui_il_percorso_del_file_sul_server",$xml);
?>
Gabriele