Author Topic: WU A non-numeric value encountered throwing reports script **Solved**  (Read 1197 times)

0 Members and 1 Guest are viewing this topic.

Offline Ian.

  • Forecaster
  • *****
  • Posts: 460
    • Chatteris Weather
Hi,

I just happend the check Station Reports and Station Graphs are both showing errors, the common demominator is the scripts pull data from WU.

Anyone else having a problem with invalid data downloaded effecting their scripts?

Ian
« Last Edit: September 18, 2017, 10:27:33 AM by Ian. »
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: WU A non-numeric value encountered throwing reports script
« Reply #1 on: September 17, 2017, 03:08:22 AM »
Hi,

I just happend the check Station Reports and Station Graphs are both showing errors, the common demominator is the scripts pull data from WU.

Anyone else having a problem with invalid data downloaded effecting their scripts?

Ian
Good morning,

The errors are "warnings" so that programmers can adapt their code. You are probably using PHP 7.1.x .

Up until PHP release 7 the language used "loosely" typing where the type of a variable changed based on the instructions accessing the variable.
A string could be added to an integer and the result could be a string or an integer, just as you wanted.
With PHP 7 a more robust "typing" is requested, hence the warnings.

Normally in a production environment the error reporting is switched off so these messages would not be displayed. It seems error reporting is default on for your site.

===

 "Invalid" or empty or non-existent data cause these errors, which is normal as not every day of a year you were or are uploading data to WU. The scripts cope with those values correctly, so the resulting tables and values are correct. The warnings could have been avaided, sorry for that  ](*,)

===

script wsreports/wsReportsDaily.php line 136 is now
Code: [Select]
$value = 1.0*$arrResults[$i][$k];change to
Code: [Select]
$value = 1.0 * (float) $arrResults[$i][$k];
===

script wsreports/wsReportsSum.php line 97 is now
Code: [Select]
$value = 1.0*$arrResults[$k];change to
Code: [Select]
$value = 1.0 * (float) $arrResults[$k];
===

Switching off the error reporting is also advisable. You can always manually switch it on by adding ?debug to the url

script wsreports/startReports.php line 1 is now
Code: [Select]
<?php  change to
Code: [Select]
<?php    ini_set('display_errors'0);        error_reporting(0);
Wim
« Last Edit: September 17, 2017, 03:11:01 AM by wvdkuil »

Offline Ian.

  • Forecaster
  • *****
  • Posts: 460
    • Chatteris Weather
Re: WU A non-numeric value encountered throwing reports script
« Reply #2 on: September 18, 2017, 10:26:54 AM »
Wim,

Thank you so much for your help, the issue has now been solved.

All the best

Ian
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline staccermaccer

  • Senior Member
  • **
  • Posts: 72
    • Weather in Ekeren and Port of Antwerp
Hello, all

I know it's an old topic but i adapted the scripts to the new version but it throws two errors in WSrEportsSum:
Code: [Select]
$arrTotals[0][$cols] = $arrTotals[0][$cols] + $value;

Is there someone who knows what to change, i presume it is also the float-thing but i don't know where to put it in this case!

Thanks for replying anyway!

Staccermaccer,

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Hello, all

I know it's an old topic but i adapted the scripts to the new version but it throws two errors in WSrEportsSum:
Code: [Select]
$arrTotals[0][$cols] = $arrTotals[0][$cols] + $value;

Is there someone who knows what to change, i presume it is also the float-thing but i don't know where to put it in this case!

Thanks for replying anyway!

Staccermaccer,
Very strange that still some users can access their WU data as most get only data for 2019 till May 23 or June 13.
But for as long as you can access your WU data: I Attach a php7+ version of the same script
Succes, Wim