WXforum.net
Web Weather => Weather Website PHP/AJAX scripting => Topic started by: zmarfak on July 20, 2021, 05:31:43 AM
-
Hi,
I think since php version 8, I have a lot of warnings regarding "Undefined array key"
Hereby an example :
Line 7430: 2021/07/20 05:51:43 [error] 36292#0: *27938318 FastCGI sent in stderr: "PHP message: PHP Warning: Undefined array key 1 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 2 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 3 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 4 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 5 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 6 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 7 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 8 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 9 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 10 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 11 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 12 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 1 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 2 in /var/www/vhosts/matar.be/httpdocs/weather/mesonet-map-genhtml-inc.php on line 267PHP message: PHP Warning: Undefined array key 3 in /var/www/vhosts/matar.be/httpdocs/weathe ...
Hereby the excerpt from mesonet-map-genhtml-inc.php
line 267 is the lines starting with list.
Anything I can do about this ?
foreach ($StationData as $key => $vals) {
list($TEMP,$HUMID,$WDIR,$WSPD,$RAIN,$BARO,$BTRND,$COND,$CTXT,$DEWPT,$GUST,$UDATE,$FTIME) = preg_split("/\,/",$vals);
if($UDATE > 1000) {
$oldestData = min($UDATE,$oldestData);
$newestData = max($UDATE,$newestData);
}
}
Thanks for your help.
As you can see on my status page the site is now on php version 8.0.8
https://www.matar.be/weather/wxstatus.php (https://www.matar.be/weather/wxstatus.php)
-
It looks like the cache file from the BNLWN for conditions (https://www.matar.be/weather/cache/BNLWN-conditions.txt) has a problem with two stations data values. They have extra new-line characters in them, and a new-line is used to mark the end of a stations record.
Here's one normal record above, two abnormal entries, and one normal entry below in the file Netherlands Wolphaertsdijk 165|16.3,89,NNE,0,0.0,1022.2,Steady,night_cloudy.gif,Metar EHWO: Overcast,14.5,,1626821554,0.203
Netherlands Ee 133|16.2,82,N,0,0.0,1020.7,Steady,night_clear.gif,Metar EHLW: Clear,13.1,0,1626821537,0.005
,day_cloudy.gif,Metar EBBR: Overcast,11.7,12,1624453009,0.057
|
Netherlands Heinenoord 124|15.7,90,E,0,0.0,1021.1,Steady,night_clear.gif,Metar EHRD: Clear,14.6,,1626821269,0.011
7
|
y,day_cloudy.gif,Metar EBAW: Mostly Cloudy,14.9,2,1624692000,0.892
|
Netherlands Heemskerk-Beijerlust 107|17.2,83,ENE,3,0.0,1022.1,Steady,night_clear.gif,Metar EHAM: Clear,14.3,2,1626821526,0.008
That same problem exists in the master file on the BNLWN at https://www.beneluxweather.net/BNLWN-conditions.txt
It's something that Wim will need to fix.. he administers the BNLWN, and his customized conditions pulling program needs a fix to remove embedded new-lines from the station data for those two stations ('Ee' and 'Heinenoord').
Best regards,
Ken
-
Ken,
thank you very much, I will contact Wim.
-
I've sent Wim a note about the issue :)
-
I've sent Wim a note about the issue :)
Thanks to both of you, working on it.
But is seems a strange problem to me, so i commented the two stations for today and will test what is happening tomorrow my time,
Wim
-
I've sent Wim a note about the issue :)
Thanks to both of you, working on it.
But is seems a strange problem to me, so i commented the two stations for today and will test what is happening tomorrow my time,
Wim
As i vaguely remember somewhere in 201? I could have added a "use last valid data if station data is not available"-feature.
The latest BNLWN-conditions.txt is read and the latest value of every station is saved before loading the fresh stations data.
I probably thought: if the station does not answer in the allowed 4 seconds, better use the previous data then no data at all.
The forced move from old to new provider introduced garbage in some files in almost all of my websites.
Mostly because of cron-jobs failing or running concurrently and DNS pointing to old sites.
Sadly also in the BNLWN-conditions.txt some garbage texts were introduced.
That garbage was handled by the scripts as real data for some (non-existing) stations.
As there can be no new data for none-existing stations, the garbage was copied to the new BNLWN-conditions.txt file as "old' data for those non-existing stations..
Setting the stations around the garbage as inactive did not help as the garbage only seemed to belong to those real-stations data.
But every line in the BNLWN-conditions.txt is a new station. Also a garbage line.
I removed the garbage lines and all is functioning OK for now.
:oops: GIGO
I forget the first lesson in programming "Garbage In results in Garbage Out"
Wim
-
Wim,
thank you for clearing this out.
:oops: GIGO
I forget the first lesson in programming "Garbage In results in Garbage Out"
Indeed a valuable statement, I used during my professional years to clarify to people that the results they get are only as good as they're input.