Author Topic: Warnings After Updating to 7.1 PHP  (Read 490 times)

0 Members and 1 Guest are viewing this topic.

Offline Bunty

  • Forecaster
  • *****
  • Posts: 2432
  • Stillwater, home of Oklahoma State University
    • Welcome to Stillwater Weather
Warnings After Updating to 7.1 PHP
« on: April 24, 2019, 05:39:26 PM »
Pardon me, if I missed the fixes, but I get several warnings in error file after upgrading to 7.1 php, such as the following:

PHP Warning:  A non-numeric value encountered in /home/public_html/stormreports.php on line 602 
PHP Warning:  A non-numeric value encountered in /home/public_html/firedangerWD.php on line 69
PHP Warning:  A non-numeric value encountered in /home/public_html/atom-advisory.php on line 1065

Is there a way to fix these things?    Doesn't seem very important, since they don't seem to be hurting script operation from what I can tell.

In a problem I was having with a different php file, an easy generic fix was done by adding this in php.ini:  allow_url_fopen=1

Also the 2nd home page using modified AltDashboard 6.95 at http://stillwaterweather.com/2ndhome.php

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Warnings After Updating to 7.1 PHP
« Reply #1 on: April 24, 2019, 05:49:55 PM »
For the atom-advisory.php, change the line above 1065 from
Code: [Select]
  $total_time = '';
to
Code: [Select]
  $total_time = 0.0;The stormreports.php script seems to be an older Curly script and likely has the same type issue (a numeric variable initialized to a blank string).
The firedangerWD.php likely has the same type issue.

Strong variable typing began enforcement with PHP 7 -- prior PHP versions were fast-and-loose with variable typing and automatically converted depending on the usage.  Now numeric, string and array have to be initialized to the respective 0.0, '', array() values first.
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 Bunty

  • Forecaster
  • *****
  • Posts: 2432
  • Stillwater, home of Oklahoma State University
    • Welcome to Stillwater Weather
Re: Warnings After Updating to 7.1 PHP
« Reply #2 on: April 30, 2019, 03:28:13 PM »
There were so many other errors and warnings in other php files, with some not functioning, for instance the AQI index, that I found it easier to change back to 5.6 php, in order to return the function of everything back to normal.   I would suggest people using 7+ php to check the function of their php scripts.

Also the 2nd home page using modified AltDashboard 6.95 at http://stillwaterweather.com/2ndhome.php

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9288
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Warnings After Updating to 7.1 PHP
« Reply #3 on: April 30, 2019, 06:32:01 PM »
That's where keeping the scripts on the site up-to-date at current levels is a big reducer of angst when major PHP versions come along.

Not all scripts have the original author still maintaining their script base, but many still do, so it's a good idea to check their download site for updates before upgrading PHP versions.

All my scripts are tested with PHP 7+ and are backward compatible to 5.6 (at current script version levels).
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