finalement ça fonctionne en mysqli , j'ai changé un peu le code également, j'en ai supprimé (trop peut être) et rajouté .
Code : Tout sélectionner
<?php
// Standard Source view option check
function check_sourceview () {
global $SITE;
if (isset($_GET['view']) && $_GET['view'] == 'sce') {
$filenameReal = __FILE__;
$download_size = filesize($filenameReal);
header('Pragma: public');
header('Cache-Control: private');
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: text/plain');
header('Accept-Ranges: bytes');
header("Content-Length: $download_size");
header('Connection: close');
readfile($filenameReal);
exit;
}
}
// Just list the PHP source?
check_sourceview();
// get the input parameters
if (isset($_GET["mm"])) {
$month = intval($_GET["mm"]);
} else {
die("No 'mm' parameter supplied");
}
if ($month == "") {
die("Invalid 'mm' parameter supplied");
}
// get the input parameters
if (isset($_GET["dd"])) {
$day = intval($_GET["dd"]);
} else {
die("No 'd' parameter supplied");
}
if ($day == "") {
die("Invalid 'dd' parameter supplied");
}
// Connect to the database
$server ="#####";
$user = "####";
$pwd = "####";
$db ="####";
$con=mysqli_connect($server,$user,$pwd,$db);
If(! $con) {
exit("Echec de la connexion");
}
$qry = "SELECT AVG(t_out_maxi), AVG(t_out_mini) FROM minimaxi WHERE substring(recdateTZ,7,2)= ".$day." and substring(recdateTZ,5,2)= ".$month;
if ($resultat = mysqli_query($con,$qry)) {
while ($row=mysqli_fetch_row($resultat))
{
$maxRec = (float)$row[0];
$minRec = (float)$row[1];
}
mysqli_free_result($resultat);
}
//$query = "SELECT DATE_FORMAT(LogDate,'%b %y'), SUM(TotRainFall) FROM dayfile WHERE LogDate >= DATE_FORMAT(CURDATE() - INTERVAL " . $interval ." MONTH, '%Y-%m-01') GROUP BY DATE_FORMAT(LogDate,'%y%c') ORDER BY DATE_FORMAT(LogDate,'%y%m')";
//SELECT year(logdate) as year, month(logdate) as month, day(logdate) as day, maxtemp, tmaxtemp, mintemp, tmintemp, round(avgtemp,1) as avgtemp, lowwindchill, tlowwindchill, highheatind, thighheatind, highhum, thighhum, lowhum, tlowhum, highdewpoint, thighdewpoint, lowdewpoint, tlowdewpoint, totrainfall, maxrainrate, tmaxrr, highhourrain, thighhourrain, highwindgust, thwindg, highavgwspeed, thavgwspeed, totwindrun, maxpress, tmaxpress, minpress, tminpress FROM dayfile WHERE day(logdate)=day(now()) and month(logdate)=month(now()) ORDER BY year(logdate) DESC
$qry = "SELECT substring(recdateUTC,1,4),t_out_maxi, t_out_mini, t_out_moy FROM minimaxi WHERE substring(recdateTZ,7,2)= ".$day." and substring(recdateTZ,5,2)= ".$month." ORDER BY substring(recdateTZ,1,4)";
//print_r ($query);
if ($resultat = mysqli_query($con,$qry)) {
while ($row=mysqli_fetch_row($resultat))
{
$title[] = $row[0];
$valMax[] = (float)$row[1];
$valMin[] = (float)$row[2];
$valAvg[] = (float)$row[3];
//$valAvg[] = array((float)$row[3]-0.1,(float)$row[3]+0.1);
$valTemp[] = array((float)$row[2], (float)$row[1]);
}
mysqli_free_result($resultat);
}
// put into a single array
$ret = array($title, $valMax,$valMin,$valAvg,$valTemp,$maxRec,$minRec);
header("Content-type: text/json");
echo json_encode($ret);
?>