Author Topic: PHP 5.6 to 7.2 issue  (Read 1618 times)

0 Members and 1 Guest are viewing this topic.

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
PHP 5.6 to 7.2 issue
« on: March 23, 2019, 03:34:25 PM »
I just switched from 5.6 to 7.2 and my dashboard wont load. Everything else seems to be working fine. Any ideas? Thanks
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 5.6 to 7.2 issue
« Reply #1 on: March 23, 2019, 03:58:57 PM »
It's likely an old function like split() or ereg() that are now deprecated and missing from PHP 7.2

Post your custom ajax-dashboard.php and I'll take a look.

Right now, a ?sce=view shows
Quote
Fatal error: Cannot redeclare langtrans() (previously declared in /homepages/8/d252567151/htdocs/ajax-dashboard.php:2260) in /homepages/8/d252567151/htdocs/common.php on line 70
so I can't see the source directly.
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 ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: PHP 5.6 to 7.2 issue
« Reply #2 on: March 23, 2019, 04:02:59 PM »
Thanks Ken. The file is attached.
« Last Edit: March 23, 2019, 04:39:22 PM by ALITTLEweird1 »
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 5.6 to 7.2 issue
« Reply #3 on: March 23, 2019, 04:26:08 PM »
Well, your code loads fine in my test with PHP 7.2.16, so that script doesn't seem to be the issue.

Your index.php page stops loading after
Quote
<!-- end AtomFeed Alert Box-->
<br/>
is displayed, so whatever script is included after that one is the likely culprit.

Can you post the source for your index.php page?
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 ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: PHP 5.6 to 7.2 issue
« Reply #4 on: March 23, 2019, 04:28:27 PM »
Index is attached.
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: PHP 5.6 to 7.2 issue
« Reply #5 on: March 23, 2019, 04:30:50 PM »
Got it... removed this line in t he index file

<?php include("./record.php"); print $breakerreport; ?>

That's the culprit file.
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: PHP 5.6 to 7.2 issue
« Reply #6 on: March 23, 2019, 04:44:23 PM »
A different error on another page...

Quote
Warning: Use of undefined constant month - assumed 'month' (this will throw an Error in a future version of PHP) in /homepages/8/d252567151/htdocs/AltAjaxDashboardConfig6.php on line 186

Line 186   $month = $today[month];   
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 5.6 to 7.2 issue
« Reply #7 on: March 23, 2019, 05:17:33 PM »
Change it to
Code: [Select]
$month = $today['month'];
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 ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: PHP 5.6 to 7.2 issue
« Reply #8 on: March 23, 2019, 05:27:51 PM »
Thanks for your help Ken. Got 1 more error..

Fatal error: Uncaught Error: [] operator not supported for strings on line 123

Line 123... $html2[] = simplexml_load_string($html);
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 5.6 to 7.2 issue
« Reply #9 on: March 23, 2019, 06:12:34 PM »
Somewhere further up in the code is probably a
Code: [Select]
$html2 = ''; .. if so, change it to
Code: [Select]
$html2 = array(); then change line 123 to
Code: [Select]
$html2 = simplexml_load_string($html);
PHP7 doesn't like redeclaration of variables and has stricter variable typing enforced.
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 ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: PHP 5.6 to 7.2 issue
« Reply #10 on: March 23, 2019, 06:22:52 PM »
There's 3 spots in the script that has $html2 = '';
Should I change them all to $html2 = array();?
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 5.6 to 7.2 issue
« Reply #11 on: March 23, 2019, 09:58:22 PM »
You need to check how the $html2 variable is used.  If it has instances where $html2[...] appears, then yes, change the prior initialization from ''; to array();

In these circumstances, it's best to watch the error_log and see what pops up and fix it one error at a time.
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 ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: PHP 5.6 to 7.2 issue
« Reply #12 on: March 23, 2019, 10:06:03 PM »
Thanks Ken.
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: PHP 5.6 to 7.2 issue
« Reply #13 on: March 23, 2019, 10:54:29 PM »
The script is kinda working now. Would removing all of "[]" do more harm than good at this point?
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 947
    • LexMAWeather
Re: PHP 5.6 to 7.2 issue
« Reply #14 on: March 24, 2019, 09:56:55 AM »
The "[]" were not the problem - the change was in how an array can be initialized (needing the explicit array() ).

Removing the braces would do harm. What the braces mean is "assign what's on the right side of the equal sign to the next element of the array". Here's an example of two pieces of code that do the same thing.

Code: [Select]
$example = array();
$example[] = "a";
$example[] = "b";
$example[] = "c";

Code: [Select]
$example = array();
$example[0] = "a";
$example[1] = "b";
$example[2] = "c";

In either case, you end up with three array elements, the indices are 0, 1, 2, and the values are "a", "b", "c".
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: PHP 5.6 to 7.2 issue
« Reply #15 on: March 30, 2019, 11:29:16 AM »
This script issue is for my warnings and advisories. After making those changes,  my advisory box is now blank. It should be showing no warnings or advisories in affect. Screenshot attached.  Any ideas on how to get that to show again? Thanks
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 5.6 to 7.2 issue
« Reply #16 on: March 30, 2019, 12:33:35 PM »
If you're still using the old AtomFeed script from Curly, you need to switch to the nws-alerts script set instead.. the AtomFeed script stopped being supported several years ago when Curly released the nws-alerts script (which is also bundled in the Base-USA template distribution).
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 ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: PHP 5.6 to 7.2 issue
« Reply #17 on: March 31, 2019, 09:41:07 PM »
I got my main page switched over to the nws-alerts script. Is there a way to make a page like this... https://www.northbendweather.com/AtomSummary.php  with the nws-alerts script?
"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 5.6 to 7.2 issue
« Reply #18 on: April 01, 2019, 10:34:55 AM »
With the nws-alerts installed in the Base-USA template, the wxadvisory.php page does that in a more succinct style.
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 ALITTLEweird1

  • Mark
  • Global Moderator
  • Forecaster
  • *****
  • Posts: 923
    • North Bend Weather
Re: PHP 5.6 to 7.2 issue
« Reply #19 on: April 15, 2019, 08:49:58 PM »
Hi Ken. I've been getting this error message "screenshot attached" on my main page since I started using the nws-alerts script. But when I hit refresh it goes away. Any ideas on this? Thanks

Code: [Select]
curl_close($ch);
  $time_stop = microtime_float();
  $total_time = '';
  $total_time += ($time_stop - $time_start);  <<<<<<<<<<<<<<<<<<<<<<< Line 875
  $time_fetch = sprintf("%01.3f", round($time_stop - $time_start, 3));
  $curl_debug .= "<!-- Time to fetch: $time_fetch sec -->\n";

"Nature can do without man, but man cannot do without nature."


Software: WeatherDisplay
Hardware: Davis VP2 + VP2 Solar + VP2 UV + Lightning Detector + Logitech Webcam + Soil temp + Soil Moisture

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP 5.6 to 7.2 issue
« Reply #20 on: April 16, 2019, 02:21:00 PM »
Ahh.. likely an older copy of atom-top-warning .. change
Code: [Select]
$total_time = ''; to
Code: [Select]
$total_time = 0.0; and PHP should stop griping about the type change from string to float.
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