-4

i am getting this error at "$hourtominute = date('H',strtotime($qData\[0\]\['totaltime'\]))*60;" and it wont tell me where the error is. Its just redmarked. can you please help me. if ur not understanding it please let me know so i can be more exactly. the code has been working for 4 years until last months. cant see why its giving me this error. i did post a picture aswell.

Here is the image

<?php 
$model = Passivatelog::model();
if(!empty($myValue)) { 
    //var_dump($myValue);

    $oPsv = Passivatelog::model();
    $oPsvRep = PassivatelogReport::model();

    $aReport = $oPsvRep->getReportByMachineId($myValue['report_machine']);
    $operator = $aReport['report_operator'];
    $machine = $aReport['report_machine'];
    $date = $aReport['report_date'];

    $aGroupedSteps = $model->getAllSteps();
?>
<div class="col-lg-6">
        <table class="table table-bordered">
            <tr>
                <th>Operator:</th>
                <th>Maskinnummer:</th>
                <th>Datum:</th>
            </tr>
            <tr>
                <td><?php echo $operator;?></td>
                <td><?php echo $machine;?></td>
                <td><?php echo $date; ?></td>
            </tr>
        </table>
        </div>
<div class="col-lg-12">
  <table class="table table-striped">
            <thead>
                <tr><th></th><th colspan="2">Temperatur</th><th colspan="2">PH Värde</th><th>Konduktivitet</th><th colspan="3">Tid</th></tr>
                <tr><th>Process</th><th>Start</th><th>Stop</th><th>Startvärde</th><th>Diff In/Ut</th><th>Medel</th><th>Start</th><th>Stop</th><th>Totaltid minuter</th></tr>
            </thead>
<?php            
    foreach($aGroupedSteps as $gstep) {
        $qData = $oPsv->getAllData($gstep->log_processname, $aReport['report_date'], $aReport['report_from'], $aReport['report_to']);
                $hourtominute = date('H',strtotime($qData[0]['totaltime']))*60;
                $minutetominute = date('i',strtotime($qData[0]['totaltime']));
                $totaltime = $hourtominute+$minutetominute;
                echo '
            <tr>
                <td>' . $gstep->log_processname . '</td>
                <td>'.$qData[0]['starttemp'].'</td>
                <td>'.$qData[0]['endtemp'].'</td>
                <td>'.(($qData[0]['startph']>0)? $qData[0]['startph']:'').'</td>
                <td>'.(($qData[0]['diffph']>0) ? number_format($qData[0]['diffph'],2) : '' ).'</td>
                <td>'.(($qData[0]['conductivity']>0)? number_format($qData[0]['conductivity'],0) : '').'</td>
                <td>'.$qData[0]['starttime'].'</td>
                <td>'.$qData[0]['endtime'].'</td>
                <td>'.$totaltime.'</td>
            </tr>';
    }
   ?> 
<tfoot></tfoot>
        </table>
</div>
<div class="clearfix"></div>
<?php
} else {
    $oPsv = Passivatelog::model();
    $oPsvRep = PassivatelogReport::model();

    $aReport = $oPsvRep->getLatestReport();
    var_dump($aReport);
    $operator = $aReport['report_operator'];
    $machine = $aReport['report_machine'];
    $date = $aReport['report_date'];
    $aGroupedSteps = $model->getAllSteps();
    if(!empty($aGroupedSteps) && !empty($aReport)) {
?>
<div class="col-lg-6">
        <table class="table table-bordered">
            <tr>
                <th>Operatör:</th>
                <th>Maskinnummer:</th>
                <th>Datum:</th>
            </tr>
            <tr>
                <td><?php echo $operator;?></td>
                <td><?php echo $machine;?></td>
                <td><?php echo $date; ?></td>
            </tr>
        </table>
        </div>
<div class="col-lg-12">
  <table class="table table-striped">
            <thead>
                <tr><th></th><th colspan="2">Temperatur</th><th colspan="2">PH Värde</th><th>Konduktivitet</th><th colspan="3">Tid</th></tr>
                <tr><th>Process</th><th>Start</th><th>Stop</th><th>Startvärde</th><th>Diff In/Ut</th><th>Medel</th><th>Start</th><th>Stop</th><th>Totaltid minuter</th></tr>
            </thead>
            <tbody>
<?php
        foreach($aGroupedSteps as $gstep) {
                $qData = $oPsv->getAllData($gstep->log_processname, $aReport['report_date'], $aReport['report_from'], $aReport['report_to']);
                $hourtominute = date('H',strtotime($qData[0]['totaltime']))*60;
                $minutetominute = date('i',strtotime($qData[0]['totaltime']));
                $totaltime = $hourtominute+$minutetominute;
                echo '
            <tr>
                <td>' . $gstep->log_processname . '</td>
                <td>'.$qData[0]['starttemp'].'</td>
                <td>'.$qData[0]['endtemp'].'</td>
                <td>'.(($qData[0]['startph']>0)? $qData[0]['startph']:'').'</td>
                <td>'.(($qData[0]['diffph']>0) ? number_format($qData[0]['diffph'],2) : '' ).'</td>
                <td>'.(($qData[0]['conductivity']>0)? number_format($qData[0]['conductivity'],0) : '').'</td>
                <td>'.$qData[0]['starttime'].'</td>
                <td>'.$qData[0]['endtime'].'</td>
                <td>'.$totaltime.'</td>
            </tr>';

        }
        ?>
            <tbody>
            <tfoot></tfoot>
        </table>           
</div>
<div class="clearfix"></div>
            <?php
    }
}
arre
  • 1
  • 2

1 Answers1

0

Data stored in array: $qData[0]['totaltime'] is not of correct format to be converted to time.

Check strtotime function in PHP manual (http://php.net/manual/en/function.strtotime.php) to check for the correct format of the string to be converted and check the data stored in that array whether it matches any of the mentioned formats in the manual.

You may need to cleanse your data, so that it works again, given it used to work before (as you have mentioned) but suddenly stopped working. It is a data related issue.

Hope this helps.

Somdip Dey
  • 3,346
  • 6
  • 28
  • 60