Author Topic: Daily records not working on php 8.0 and 8.1  (Read 1215 times)

0 Members and 1 Guest are viewing this topic.

Offline hcorrin

  • Senior Member
  • **
  • Posts: 51
    • Ballaugh Weather
Daily records not working on php 8.0 and 8.1
« on: July 18, 2022, 05:28:27 PM »
i have put this in a new post
i am trying to see what does and does not work on php 8.0 or 8.1
the wxnoaarecords.php fails to load correctly http://ballaugh.no-ip.biz:59202/WD-AJAX/wxnoaarecords.php
has anybody got the wxnoaarecords.php to run on php 8.0

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8766
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Daily records not working on php 8.0 and 8.1
« Reply #1 on: July 18, 2022, 06:22:01 PM »
The last thing that runs to completion on that page was the menubar.php 
Code: [Select]
</div><!-- end doNotPrint -->
<!-- end of menubar -->

Can you post the source of the page as a .txt attachment?  I'll take a look.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8766
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Daily records not working on php 8.0 and 8.1
« Reply #2 on: July 18, 2022, 06:33:45 PM »
I think I've found the issue(s) with the wxrecords-include.php script.  malformed constants to date().

Change
Code: [Select]
$month_number = date(n);
$month = langtransstr($months[$month_number-1]);
$year = date(Y);
to
Code: [Select]
$month_number = date('n');
$month = langtransstr($months[$month_number-1]);
$year = date('Y');
also change
Code: [Select]
    $year = date(Y);
    $day = date(j);
to
Code: [Select]
    $year = date('Y');
    $day = date('j');
and the script should stop having a fatal error.

It's always a good thing to check the error_log for your webserver, or enable full error display by adding
Code: [Select]
error_reporting(E_ALL);ini_set('display_errors','1'); to the script to see where it's failing interactively.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline hcorrin

  • Senior Member
  • **
  • Posts: 51
    • Ballaugh Weather
Re: Daily records not working on php 8.0 and 8.1
« Reply #3 on: July 18, 2022, 06:48:32 PM »
i think i already have those amendments but not the error bit have added that to both files on  http://ballaugh.no-ip.biz:59202/WD-AJAX/wxnoaarecords.php
have attached 2 files

the synology error logs are hidden some where but not sure how to easily access them

Thanks

Harold
« Last Edit: July 18, 2022, 07:10:07 PM by hcorrin »

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8766
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Daily records not working on php 8.0 and 8.1
« Reply #4 on: July 18, 2022, 08:08:53 PM »
This one is harder to fix.. the Fatal error cited was:

Quote
Fatal error: Uncaught TypeError: Unsupported operand types: string + float in wxnoaarecords-include.php:192 Stack trace:
#0 wxnoaarecords.php(117): require_once()
#1 {main} thrown in wxnoaarecords-include.php on line 192

That will take a good amount of investigation to root out the cause of the issue.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8766
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Daily records not working on php 8.0 and 8.1
« Reply #5 on: July 19, 2022, 01:07:01 PM »
Ok, too many Fatal errors in the script to fix.

The issue is (from stackoverflow )
Quote
The error you've provided only occurs on PHP 8 and it is because you're trying to add a string to an integer. In previous versions the error message used to be "A non-numeric value encountered" which in some situations made the issue a lot clearer.

    In PHP v5.6 you would receive no error at all (and the code would work fine)
    In PHP v7 you would be informed with a WARNING that "A non-numerical value was encountered"
    In PHP v8 you are informed with a FATAL error that "Uncaught TypeError: Unsupported operand types: string + int"
  I've corrected 20 errata so far, and there's no end in sight.  I suggest the wxnoaareports/wxnoaareports-include.php scripts be deprecated with PHP 8.0 until someone with more time/patience is willing to slog through fixing these scripts for modern PHP.

Regrets,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline hcorrin

  • Senior Member
  • **
  • Posts: 51
    • Ballaugh Weather
Re: Daily records not working on php 8.0 and 8.1
« Reply #6 on: July 19, 2022, 02:34:58 PM »
ok
thanks for trying will retire those scripts when November comes

Harold

Offline hcorrin

  • Senior Member
  • **
  • Posts: 51
    • Ballaugh Weather
Re: Daily records not working on php 8.0 and 8.1
« Reply #7 on: July 20, 2022, 04:08:50 PM »
Hi Ken
i have just been having a play with this i commented the lines causing the fatal errors and if they had an { on the end moved it down a line before commenting the line and some how i have it partially working http://ballaugh.no-ip.biz:59202/WD-AJAX/wxnoaarecords.php was expecting the dreaded error 500 considering i know little about php
have attached the amended wxnoaarecords-include
commented lines are 192,222,364,366,367,376,378,379,388,390,391,399,403,404,413,417,418 in the attached strangely they mostly relate to snow
« Last Edit: July 20, 2022, 06:08:27 PM by hcorrin »

Offline hcorrin

  • Senior Member
  • **
  • Posts: 51
    • Ballaugh Weather
Re: Daily records not working on php 8.0 and 8.1
« Reply #8 on: July 25, 2022, 03:10:45 PM »
ok have had more of a play with this http://ballaugh.no-ip.biz:59202/WD-AJAX/wxnoaarecords1.php has no snow or pressure data displayed
and http://ballaugh.no-ip.biz:59202/WD-AJAX/wxnoaarecords4.php display data for all but snow for month not working and snow year only shows January data
i have attached my working files the data file locations will need to be changed
version 5 is version 4 with the full errors display turned on  and there is a lot of them so is only to test  http://ballaugh.no-ip.biz:59202/WD-AJAX/wxnoaarecords5.php
version 2 shows pressure data if needed   http://ballaugh.no-ip.biz:59202/WD-AJAX/wxnoaarecords2.php
version 3 includes daily snow but not month or year  http://ballaugh.no-ip.biz:59202/WD-AJAX/wxnoaarecords3.php
this has been a trial and error job as i am no use at php but it may be of use until a better version comes along
the unit the links ref to is running php 8.0
Harold
« Last Edit: July 26, 2022, 02:33:18 PM by hcorrin »

Offline dasman

  • Forecaster
  • *****
  • Posts: 491
    • Wx Peotone
Re: Daily records not working on php 8.0 and 8.1
« Reply #9 on: July 25, 2022, 05:09:52 PM »
Thanks. I do not have WD so I loaded your files (version 4) and they are working on PHP 8.1 on GoDaddy. https://www.peotoneweather.com/wxnoaarecords4.php.
If you do any more changes to it could you let me know?

Thanks again

Dave
Dave Sommerfed
Peotone Illinois USA
CW7762, KILPEOT1
NWS COOP, CoCoRaHS, Spotter Network

Offline hcorrin

  • Senior Member
  • **
  • Posts: 51
    • Ballaugh Weather
Re: Daily records not working on php 8.0 and 8.1
« Reply #10 on: July 25, 2022, 05:21:50 PM »
hi glad it of us
i think you need to change the years on lines 61 and 63 plus the location in line 62 of your wxnoaarecords4.php
if i do make any more changes i will post here
Harold
« Last Edit: July 25, 2022, 05:23:34 PM by hcorrin »

Offline dasman

  • Forecaster
  • *****
  • Posts: 491
    • Wx Peotone
Re: Daily records not working on php 8.0 and 8.1
« Reply #11 on: July 25, 2022, 05:36:54 PM »
Thaks again. I made the changes.
Dave Sommerfed
Peotone Illinois USA
CW7762, KILPEOT1
NWS COOP, CoCoRaHS, Spotter Network

Offline Weerstation

  • Member
  • *
  • Posts: 36
Re: Daily records not working on php 8.0 and 8.1
« Reply #12 on: October 07, 2022, 07:54:01 AM »
 =D&gt;

Thanks Guys!  [tup]

This helped me to restore my wxnoaarecords running from saratoga template.
It didn't work anymore after 8.1.10 php update.

I probably had a very old version of wxnoaarecords while I had no include file.
Also I had to set the dailynoaa path in the code it self.

But, figured it all out.

Thanks again for all the work.  [tup] =D&gt;