Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

PHP Notice - Undefined offset

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
User avatar
PaulMy
Posts: 3777
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

PHP Notice - Undefined offset

Post by PaulMy »

I am getting this repeating error logged on my www.komokaweather.ca site
[05-Aug-2019 12:33:44 America/Toronto] PHP Notice: Undefined offset: 1 in /home/psoykkrhjuz3/public_html/komokaweather-ca/ajax-dashboard.php on line 1184
[05-Aug-2019 12:33:44 America/Toronto] PHP Notice: Undefined offset: 2 in /home/psoykkrhjuz3/public_html/komokaweather-ca/ajax-dashboard.php on line 1185
[05-Aug-2019 12:33:44 America/Toronto] PHP Notice: Undefined offset: 3 in /home/psoykkrhjuz3/public_html/komokaweather-ca/ajax-dashboard.php on line 1186
This is lines 1183 to 1087

Code: Select all

function moonphase ($WDmoonage) {

  preg_match_all('|(\d+)|is',$WDmoonage,$matches);
//  print "<!-- matches=\n" . print_r($matches,true) . "-->\n";
From http://www.komokaweather.ca/check-fetch ... w=versions all scripts are current.

Any suggestions?

Enjoy,
Paul
Davis Vantage Pro2+
C1 www.komokaweather.com/komokaweather-ca
MX www.komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX www.komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX www. komokaweather.com/cumulusmx4/index.htm

Image
User avatar
ConligWX
Posts: 1573
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis vPro2+ w/DFARS + AirLink
Operating System: Ubuntu 22.04 LTS
Location: Bangor, NI
Contact:

Re: PHP Notice - Undefined offset

Post by ConligWX »

Hi Paul.

I am seeing

Code: Select all

Notice: Undefined offset: 1 in /home/psoykkrhjuz3/public_html/weather28/metar/wsMetarTxt.php on line 82
Notice: Undefined offset: 1 in /home/psoykkrhjuz3/public_html/weather28/metar/wsMetarTxt.php on line 88
Notice: Array to string conversion in /home/psoykkrhjuz3/public_html/weather28/metar/wsMetarTxt.php on line 93
at the top of your index page on http://www.komokaweather.com/weather28/ too.
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus with Daytime FARS • WeatherLink Live • Davis AirLink • PurpleAir •

Image
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: PHP Notice - Undefined offset

Post by saratogaWX »

PaulMy wrote: Mon 05 Aug 2019 4:46 pm I am getting this repeating error logged on my www.komokaweather.ca site
[05-Aug-2019 12:33:44 America/Toronto] PHP Notice: Undefined offset: 1 in /home/psoykkrhjuz3/public_html/komokaweather-ca/ajax-dashboard.php on line 1184
[05-Aug-2019 12:33:44 America/Toronto] PHP Notice: Undefined offset: 2 in /home/psoykkrhjuz3/public_html/komokaweather-ca/ajax-dashboard.php on line 1185
[05-Aug-2019 12:33:44 America/Toronto] PHP Notice: Undefined offset: 3 in /home/psoykkrhjuz3/public_html/komokaweather-ca/ajax-dashboard.php on line 1186
This is lines 1183 to 1087

Code: Select all

function moonphase ($WDmoonage) {

  preg_match_all('|(\d+)|is',$WDmoonage,$matches);
//  print "<!-- matches=\n" . print_r($matches,true) . "-->\n";
From http://www.komokaweather.ca/check-fetch ... w=versions all scripts are current.

Any suggestions?

Enjoy,
Paul
Those are from the last 3 lines in

Code: Select all

  preg_match_all('|(\d+)|is',$WDmoonage,$matches);
//  print "<!-- matches=\n" . print_r($matches,true) . "-->\n";
  $mdays = $matches[1][0];
  $mhours = $matches[1][1];
  $mmins = $matches[1][2];
  $mpct  = $matches[1][3];
The call to the function happens in
Line 859: alt="<?php $t1 = moonphase($moonage) . ", Moon at $moonagedays days in cycle";

The $moonage value is constructed by

Line 300: if(!isset($moonage)) {$moonage = 'Moon age: '.$mooninfo->age.','.$mooninfo->ill.'%'; }

if it is missing from the CUdefs.php file (which it normally is).

The cMooninfo is returning
<!-- cGetMoonInfo returns
stdClass Object
(
[date] => 1566008403
[datetxt] => Sat, 17-Aug-2019 02:20 GMT
[age] => 15 days, 23 hours, 8 minutes
[ill] => 98
[pic] => 15
[phase] => Waning Gibbous
so $moonage should contain 'Moon age: 15 days, 23 hours, 8 minutes,98%' so the

preg_match_all('|(\d+)|is'

should pick up the 4 number values from that string.
I suggest you change the

Code: Select all

//  print "<!-- matches=\n" . print_r($matches,true) . "-->\n";
to

Code: Select all

  print "<!-- WDmoonage='$WDmoonage', matches=\n" . print_r($matches,true) . "-->\n";
so the argument and results can be seen in a view-source of the page.
User avatar
PaulMy
Posts: 3777
Joined: Sun 28 Sep 2008 11:54 pm
Weather Station: Davis VP2 Plus 24-Hour FARS
Operating System: Windows8 and Windows10
Location: Komoka, ON Canada
Contact:

Re: PHP Notice - Undefined offset

Post by PaulMy »

Thanks Ken,
I have made the edit. Lines 1177 to 1187 are now

Code: Select all

// "Moon age: 10 days,10 hours,41 minutes,80%"

function moonphase ($WDmoonage) {

  preg_match_all('|(\d+)|is',$WDmoonage,$matches);

print "<!-- WDmoonage='$WDmoonage', matches=\n" . print_r($matches,true) . "-->\n";
  $mdays = $matches[1][0];
  $mhours = $matches[1][1];
  $mmins = $matches[1][2];
  $mpct  = $matches[1][3];
but still get the same in the error_log -
[19-Aug-2019 00:15:26 America/Toronto] PHP Notice: Undefined offset: 1 in /home/psoykkrhjuz3/public_html/komokaweather-ca/ajax-dashboard.php on line 1185
[19-Aug-2019 00:15:26 America/Toronto] PHP Notice: Undefined offset: 2 in /home/psoykkrhjuz3/public_html/komokaweather-ca/ajax-dashboard.php on line 1186
[19-Aug-2019 00:15:26 America/Toronto] PHP Notice: Undefined offset: 3 in /home/psoykkrhjuz3/public_html/komokaweather-ca/ajax-dashboard.php on line 1187
I have made a slight modification to ajax-dashboard.php to display the Sager forecast, and presume that has not impacted the error message?

Regards,
Paul
Davis Vantage Pro2+
C1 www.komokaweather.com/komokaweather-ca
MX www.komokaweather.com/cumulusmx/index.htm /index.html /index.php
MX www.komokaweather.com/cumulusmxwll/index.htm /index.html /index.php
MX www. komokaweather.com/cumulusmx4/index.htm

Image
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: PHP Notice - Undefined offset

Post by saratogaWX »

The view-source of the page now shows
<!-- WDmoonage='18', matches=
Array
(
[0] => Array
(
[0] => 18
)

[1] => Array
(
[0] => 18
)

)
-->
so the $moonage string passed to it is not in the expected form (missing the hours seconds and % illumination values).

Check your site for anything that might set $moonage variable (a mod perhaps).
Post Reply