le 30/08/2007 à 15:50
Probléme pour generer un cvs
Bonjour,
Je doit generer un cvs avec le script ci dessous.
Mais il me genere une erreur dans le cvs :
Si quelqu'un pouvais me dire ou ce trouve l'erreur car perso je ne la trouve pas merci d'avance pour l'aide.
Je doit generer un cvs avec le script ci dessous.
<?php
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=Historique_" . date("Ymd").".cvs");
$csv_output = "Month,DeviceName,InterfaceName,InterfaceDesc,Minor,Major,Critical";
$csv_output .= "\n";
include("../include/connection.php");
//Lecture de la data base
$query = ("
select
YEAR(FROM_UNIXTIME(History.eventdate)) as Year,
MONTH(FROM_UNIXTIME(History.eventdate)) as Month,
Devices.name as DeviceName,
Interfaces.name as InterfaceName,
Devices.name2 as devicesName2,
Interfaces.description as InterfaceDesc,
SUM(case StatusTypes.name when 'Normal' then 1 else 0 end) as Normal,
SUM(case StatusTypes.name when 'Minor' then 1 else 0 end) as Minor,
SUM(case StatusTypes.name when 'Major' then 1 else 0 end) as Major,
SUM(case StatusTypes.name when 'Critical' then 1 else 0 end) as Critical
from
History
inner join StatusTypes on History.statusid = StatusTypes.id
inner join Cells on History.cellid = Cells.id
inner join Interfaces on Cells.interfaceid = Interfaces.id
inner join ServiceTypes on Cells.serviceid = ServiceTypes.id
inner join Devices on Interfaces.deviceid = Devices.id
where
ServiceTypes.name = 'FEC'
group by
YEAR(FROM_UNIXTIME(History.eventdate)),
MONTH(FROM_UNIXTIME(History.eventdate)),
Devices.name,
Interfaces.name,
Interfaces.description
$result = mysql_query($query)
");
while($row = mysql_fetch_array($result)) {
$cvs_output = "$row[Month],$row[DeviceName],$row[InterfaceName],$row[devicesName2],$row[InterfaceDesc],$row[Ninor],$row[Major],$row[Critical]\n";
}
print $csv_output;
exit;
?>
Mais il me genere une erreur dans le cvs :
<b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>/var/www/monitoring/historique/cvs.php</b> on line <b>43</b><br />
Si quelqu'un pouvais me dire ou ce trouve l'erreur car perso je ne la trouve pas merci d'avance pour l'aide.