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.