Welcome to the Cumulus Support forum.

Latest Cumulus MX release v3.3.0 build 3063 - 10 January 2020.
    Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014

    See the Wiki for downloading either version.

    PHP Notice - Undefined offset

    Discussion of Ken True's web site templates

    Moderator: saratogaWX

    Post Reply
    User avatar
    PaulMy
    Posts: 2031
    Joined: Sun 28 Sep 2008 11:54 pm
    Weather Station: Davis Vantage Pro 2+ w/Envoy USB
    Operating System: Windows-8
    Location: Komoka, ON Canada
    Contact:

    PHP Notice - Undefined offset

    Post by PaulMy » 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

    User avatar
    ConligWX
    Posts: 751
    Joined: Mon 19 May 2014 10:45 pm
    Weather Station: Davis VPro2 Plus +DFARS
    Operating System: MeteoBridge Nano SD
    Location: Bangor, NI
    Contact:

    Re: PHP Notice - Undefined offset

    Post by ConligWX » Fri 16 Aug 2019 6:14 pm

    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 + DFARS - Meteobrige Nano SD + Saratoga Templates

    User avatar
    saratogaWX
    Posts: 1008
    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 » Sat 17 Aug 2019 2:29 am

    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: 2031
    Joined: Sun 28 Sep 2008 11:54 pm
    Weather Station: Davis Vantage Pro 2+ w/Envoy USB
    Operating System: Windows-8
    Location: Komoka, ON Canada
    Contact:

    Re: PHP Notice - Undefined offset

    Post by PaulMy » Mon 19 Aug 2019 4:29 am

    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

    User avatar
    saratogaWX
    Posts: 1008
    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 » Mon 19 Aug 2019 2:29 pm

    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