Web Weather > Weather Website PHP/AJAX scripting
Undefined Array After Updating to PHP 8.1
scottct1:
Moved the site from PHP 7.4 up to 8.1 today. Most of the page came up blank. (I am using the Burnsville Alternative script)
So I went over to Kens site and downloaded the latest version. I updated the AltAjaxDashboardConfig6.php with my settings and uploaded and overwrote all the files and everything is displaying... well almost.
Below the header I see the following...
--- Quote ---Warning: Undefined array key 0 in /home/weather/public_html/raintodate.php on line 124
Warning: Trying to access array offset on value of type null in /home/weather/public_html/raintodate.php on line 124
Warning: Undefined array key 1 in /home/weather/public_html/raintodate.php on line 124
Warning: Trying to access array offset on value of type null in /home/weather/public_html/raintodate.php on line 124
Warning: Undefined array key 2 in /home/weather/public_html/raintodate.php on line 124
Warning: Trying to access array offset on value of type null in /home/weather/public_html/raintodate.php on line 124
Warning: Undefined array key 3 in /home/weather/public_html/raintodate.php on line 124
Warning: Trying to access array offset on value of type null in /home/weather/public_html/raintodate.php on line 124
Warning: Undefined variable $month_rain in /home/weather/public_html/raintodate.php on line 127
--- End quote ---
Not sure what this means or how to get rid of it.
The site is https://NewingtonWeather.COM
It is running off of WeatherDisplay with a Davis Vantage 2 Plus with Solar and UV, as well as lightning from Tempest.
If Ken or anyone can help out I would be very greatful. :D Thank you!
saratogaWX:
Did you also replace the other php scripts in the update .zip?
scottct1:
Yes uploaded them all. Including the directories.
Just deleted them and reuploaded them now. Still getting the same thing. I assume the update zip file is this one "https://saratoga-weather.org/legacy-scripts/AltAjaxDashboard695g.zip"
Thanks Ken for your quick reply.
saratogaWX:
Try replacing in raintodate.php
--- Code: ---function get_mtd_rain ($start_year,$day,$month,$year,$loc)
{
$years = $year - $start_year;
$months = 0;
for ($i = 0 ; $i < $years ; $i++)
{
$filename = "dailynoaareport" . ( $month) . ($start_year + $i) . ".htm";
if (file_exists($loc . $filename) )
{
$data[0] = getnoaafile($loc . $filename);
$months = $months + 1;
// Now get data from the dailynoaareport for this month from the 1st to today's date'.
for ($d = 0 ; $d < $day ; $d++)
{
$rain = $data[0][$d][8];
if ($rain != "")
{
$month_rain = $month_rain + $rain;
}
}
}
}
--- End code ---
with
--- Code: ---function get_mtd_rain ($start_year,$day,$month,$year,$loc)
{
$years = $year - $start_year;
$months = 0;
$month_rain = 0;
for ($i = 0 ; $i < $years ; $i++)
{
$filename = "dailynoaareport" . ( $month) . ($start_year + $i) . ".htm";
if (file_exists($loc . $filename) )
{
$data[0] = getnoaafile($loc . $filename);
$months = $months + 1;
// Now get data from the dailynoaareport for this month from the 1st to today's date'.
for ($d = 0 ; $d < $day ; $d++)
{
$rain = isset($data[0][$d][8])?$data[0][$d][8]:'';
if ($rain != "")
{
$month_rain = $month_rain + $rain;
}
}
}
}
--- End code ---
scottct1:
Thanks Ken, tried it and am getting an error of Parse error: Unclosed '{' on line 124 does not match ')' in /home/weather/public_html/raintodate.php on line 125
Here is the code after I changed it... (Including the entire section, incase I messed something up)
--- Code: ---########## Functions ##########################################################
function get_mtd_rain ($start_year,$day,$month,$year,$loc)
{
$years = $year - $start_year;
$months = 0;
$month_rain = 0;
for ($i = 0 ; $i < $years ; $i++)
{
$filename = "dailynoaareport" . ( $month) . ($start_year + $i) . ".htm";
if (file_exists($loc . $filename) )
{
$data[0] = getnoaafile($loc . $filename);
$months = $months + 1;
// Now get data from the dailynoaareport for this month from the 1st to today's date'.
for ($d = 0 ; $d < $day ; $d++)
{
$rain = isset($data[0][$d][8])?$data[0][$d][8]):'';
if ($rain != "")
{
$month_rain = $month_rain + $rain;
}
}
}
}
if ($months == 0) {
$mtd_rain = 0;
} else {
$mtd_rain = $month_rain / $months;
}
return $mtd_rain;
}
############################################################################
# End of Functions
############################################################################
--- End code ---
Navigation
[0] Message Index
[#] Next page
Go to full version