In my old system I had a hightcharts chart that imports the records values from my database table, however, when using the same model on another system, the following error began to appear:
Notice: Undefined index: SCJan in C: \ Program Files (x86) \ EasyPHP5.2.10 \ www \ Sis_Tam \ index.php
Notice: Undefined index: SDJan in C: \ Program Files (x86) \ EasyPHP5.2.10 \ www \ Sis_Tam \ index.php
Notice: Undefined index: SEJan in C: \ Program Files (x86) \ EasyPHP5.2.10 \ www \ Sis_Tam \ index.php
Follow the code on my page with the chart:
Part in php responsible for doing the import:
<script src="../../code/modules/series-label.js"></script>
<script src="../../code/modules/exporting.js"></script>
<div id="container"></div>
<?php
/*-------------------------------------Janeiro ---------------------------------*/
require_once("strcon.php");
$totaSAJ = 0;
$totaSBJ = 0;
$totaSCJ = 0;
$totaSDJ = 0;
$totaSEJ = 0;
$SAJ = "SELECT COUNT(ID) AS SAJan FROM pedidos WHERE SERVICO = 'Serviço A' and MES = 'JAN' and ANO = '2018'";
$SBJ = "SELECT COUNT(ID) AS SBJan FROM pedidos WHERE SERVICO = 'Serviço B' and MES = 'JAN' and ANO = '2018'";
$SCJ = "SELECT COUNT(ID) AS SCJan FROM pedidos WHERE SERVICO = 'Serviço C' and MES = 'JAN' and ANO = '2018'";
$SDJ = "SELECT COUNT(ID) AS SDJan FROM pedidos WHERE SERVICO = 'Serviço D' and MES = 'JAN' and ANO = '2018'";
$SEJ = "SELECT COUNT(ID) AS SEJan FROM pedidos WHERE SERVICO = 'Serviço E' and MES = 'JAN' and ANO = '2018'";
$consultasaj = mysqli_query($strcon, "SELECT COUNT(ID) AS SAJan FROM pedidos WHERE SERVICO = 'Serviço A' and MES = 'JAN' and ANO = '2018'");
$consultasbj = mysqli_query($strcon, "SELECT COUNT(ID) AS SBJan FROM pedidos WHERE SERVICO = 'Serviço B' and MES = 'JAN' and ANO = '2018'");
$consultascj = mysqli_query($strcon, "SELECT COUNT(ID) AS SCJan FROM pedidos WHERE SERVICO = 'Serviço C' and MES = 'JAN' and ANO = '2018'");
$consultasdj = mysqli_query($strcon, "SELECT COUNT(ID) AS SDJan FROM pedidos WHERE SERVICO = 'Serviço D' and MES = 'JAN' and ANO = '2018'");
$consultasej = mysqli_query($strcon, "SELECT COUNT(ID) AS SEJan FROM pedidos WHERE SERVICO = 'Serviço E' and MES = 'JAN' and ANO = '2018'");
if ($consultasaj = mysqli_query($strcon, $SAJ)) {
if ($rowsaj = mysqli_fetch_assoc($consultasaj)) {
$totaSAJ = $rowsaj['SAJan']; //Seta o total
}
mysqli_free_result($consultasaj);
} else {
}
if ($consultasbj = mysqli_query($strcon, $SBJ)) {
if ($rowsbj = mysqli_fetch_assoc($consultasbj)) {
$totaSBJ = $rowsbj['SBJan']; //Seta o total
}
mysqli_free_result($consultasbj);
} else {
}
if ($consultascj = mysqli_query($strcon, $SCJ)) {
if ($rowscj = mysqli_fetch_assoc($consultascj)) {
$totaSCJ = $rowsbj['SCJan']; //Seta o total
}
mysqli_free_result($consultascj);
} else {
}
if ($consultasdj = mysqli_query($strcon, $SDJ)) {
if ($rowsdj = mysqli_fetch_assoc($consultasdj)) {
$totaSDJ = $rowsbj['SDJan']; //Seta o total
}
mysqli_free_result($consultasdj);
} else {
}
if ($consultasej = mysqli_query($strcon, $SEJ)) {
if ($rowsej = mysqli_fetch_assoc($consultasej)) {
$totaSEJ = $rowsbj['SEJan']; //Seta o total
}
mysqli_free_result($consultasej);
} else {
}
Charge party:
<script type="text/javascript">
Highcharts.chart('container', {
title: {
text: 'Indicador anual de serviços'
},
subtitle: {
text: ''
},
xAxis: [{
categories: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun',
'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
crosshair: true
}],
yAxis: {
title: {
text: ''
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
series: [{
name: 'Serviço A',
data: [<?php echo $rowsaj['SAJan'];?>, <?php echo $rowsaf['SAFev'];?>,<?php echo $rowsamar['SAMar'];?>, <?php echo $rowsaabr['SAAbr'];?>, <?php echo $rowsamai['SAMai'];?>, <?php echo $rowsajun['SAJun'];?>, <?php echo $rowsajul['SAJul'];?>, <?php echo $rowsaago['SAAgo'];?>, <?php echo $rowsaset['SASet'];?>, <?php echo $rowsaout['SAOut'];?>, <?php echo $rowsanov['SANov'];?>, <?php echo $rowsadez['SADez'];?>]
}, {
name: 'Serviço B',
data: [<?php echo $rowsbj['SBJan'];?>,<?php echo $rowsbf['SBFev'];?>, <?php echo $rowsbmar['SBMar'];?>, <?php echo $rowsbabr['SBAbr'];?>, <?php echo $rowsbmai['SBMai'];?>, <?php echo $rowsbjun['SBJun'];?>,<?php echo $rowsbjul['SBJul'];?>, <?php echo $rowsbago['SBAgo'];?>, <?php echo $rowsbset['SBSet'];?>, <?php echo $rowsbout['SBOut'];?>, <?php echo $rowsbnov['SBNov'];?>, <?php echo $rowsbdez['SBDez'];?>]
}, {
name: 'Serviço C',
data: [<?php echo $rowscj['SCJan'];?>, <?php echo $rowscf['SCFev'];?>, <?php echo $rowscmar['SCMar'];?>, <?php echo $rowscabr['SCAbr'];?>, <?php echo $rowscmai['SCMai'];?>, <?php echo $rowscjun['SCJun'];?>, <?php echo $rowscjul['SCJul'];?>, <?php echo $rowscago['SCAgo'];?>, <?php echo $rowscset['SCSet'];?>, <?php echo $rowscout['SCOut'];?>, <?php echo $rowscnov['SCNov'];?>, <?php echo $rowscdez['SCDez'];?>]
}, {
name: 'Serviço D',
data: [<?php echo $rowsdj['SDJan'];?>, <?php echo $rowsdf['SDFev'];?>, <?php echo $rowsdmar['SDMar'];?>, <?php echo $rowsdabr['SDAbr'];?>, <?php echo $rowsdmai['SDMai'];?>, <?php echo $rowsdjun['SDJun'];?>, <?php echo $rowsdjul['SDJul'];?>, <?php echo $rowsdago['SDAgo'];?>, <?php echo $rowsdset['SDSet'];?>,<?php echo $rowsdout['SDOut'];?>, <?php echo $rowsdnov['SDNov'];?>, <?php echo $rowsddez['SDDez'];?>]
}, {
name: 'Serviço E',
data: [<?php echo $rowsej['SEJan'];?>, <?php echo $rowsef['SEFev'];?>, <?php echo $rowsemar['SEMar'];?>, <?php echo $rowseabr['SEAbr'];?>, <?php echo $rowsemai['SEMai'];?>, <?php echo $rowsejun['SEJun'];?>,<?php echo $rowsejul['SEJul'];?>,<?php echo $rowseago['SEAgo'];?>, <?php echo $rowseset['SESet'];?>, <?php echo $rowseout['SEOut'];?>, <?php echo $rowsenov['SENov'];?>, <?php echo $rowsedez['SEDez'];?>]
}],
responsive: {
rules: [{
condition: {
tickInterval: 1,
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
</script>
THE LINES THAT MAKE ERROR ARE:
$ totaSCJ = $ rowsbj ['SCJan'];
$ totaSDJ = $ rowsbj ['SDJan'];
$ totaSEJ = $ rowsbj ['SEJan'];
PS: I did the same code as of January for other months, so appear more months on the chart, but like all give the same error only found it necessary to place the code of the months to facilitate understanding.
I need a lot to solve this problem today yet, so if you can help me I would be very grateful. :)
-------------------------------- UPDATE -------------- -----------------
ALL ERRORS WERE RESOLVED WHEN I COLLECT AN ISSET BEFORE THE% OF% BUT BUT STILL THE GRAPH DOES NOT APPEAR ON THE SCREEN.