Author Topic: Undefined variable after Saratoga update  (Read 1127 times)

0 Members and 1 Guest are viewing this topic.

Offline chrisgrainger

  • Contributor
  • ***
  • Posts: 127
    • Top of The Rideau
Undefined variable after Saratoga update
« on: June 27, 2023, 11:57:30 AM »
Good morning,


I have been using Gerry Wilkins Sun Piechart code in my site's menubar.php for many years now.  Today, I updated my Saratoga template and I am now getting an Undefined Error message shown in the attached.  I have included the code mentioned.... line 120 is the line below that says "if ($displayYesterday) {"


It should be noted that menubar.php was not a file included in the Saratoga update.

If anyone could give me a quick hit in the head as to how to define that variable properly, I'd appreciate it.


Cheers!


Chris








Code: [Select]
<!-- Code from Gerry Wilkins to display a Sunlight Piechart
    includes civil, nautical, and astronomical twilight -->


<p class="sideBarTitle"><?php langtrans(&#39;Sunlight Hours&#39;); ?></p>
    <div class="sideBarText" style="font-weight:lighter; font-size: 6.5pt; text-align: center; margin-bottom:4px; line-height:135%">
          <?php
         
include("heavens.php"); 
         
$hrsOfSunLight = array(); // [0] = yesterday, [1] = today, [2] = tomorrow
         
$changeinday2 get_changeinday();
#         echo &#39;$changeinday2 = &#39;.$changeinday2.&#39;<br/>&#39;; // Debug Code
           //Make piechart
         
$timebits explode(":"$hrsOfSunLight[1]); // Today
         
$testresult $timebits[0] + $timebits[1]/60;
            
$test1jus=round(($testresult/24)*100,1);
            
$testmorker=100-$test1jus;
        
?>

            <span class="thisPage" style="position: relative; font-weight:lighter">
          <?php
           $time_arr 
explode(&#39;:&#39;, $changeinday2);
         
$time_arr[0]>0?$cidsign = &#39;+&#39;: $cidsign =&#39;-&#39;;
         
if ($time_arr[1]< 5) {
                  if (
$displayYesterday) {
                     
$time_arr2 explode(&#39;:&#39;, $hrsOfSunLight[0]); // Yesterday
                     
echo (int)$time_arr2[0] . " hrs " . (int)$time_arr2[1] . " min " . (int)$time_arr2[2]." sec";
                     echo &
#39;<br/>Sunlight Yesterday<br/>&#39;;
                  
}
            
$time_arr explode(&#39;:&#39;, $hrsOfSunLight[1]); // Today
            
echo (int)$time_arr[0] . " hrs " . (int)$time_arr[1] . " min " . (int)$time_arr[2]." sec";
            echo &
#39;<br/>of Sunlight Today&#39;;
        
?>

                  <?php echo &#39;<br/>Which is &#39;;
            
$time_arr explode(&#39;:&#39;, $changeinday2);
                  
echo (((int)$time_arr[1]>0)?(&#39;<br/>&#39;.(int)$time_arr[1] . &#39; min &#39;):&#39; &#39;) . $time_arr[2];
                  
echo (substr($time_arr[0],0,1) != "-")?&#39; sec Longer&#39;:&#39; sec Shorter&#39;; // &#39;-&#39; when getting shorter
            
echo (&#39;<br/>Than Yesterday<br/>&#39;);
                  
if ($displayTomorrow) {
                     
$time_arr3 explode(&#39;:&#39;, $hrsOfSunLight[2]); // Tomorrow
                     
echo (int)$time_arr3[0] . " hrs " . (int)$time_arr3[1] . " min " . (int)$time_arr3[2]." sec";
                     echo &
#39;<br/>of Sunlight Tomorrow<br/>&#39;;
                  
?>

            </span>
            <span class="thisPage" style="font-size:7px"><br/>(Noon)</span>
            <a style="width:109px" href="<?php echo $sunLightPieLink?>" target="_blank" title="Astronomy Page in New Tab"><img style="width:109px; margin-left:auto; margin-right:auto" src="<?php echo getUniqueImageURL(&#39;./cache/heavenpie.png&#39;)?>" alt="graph"/></a>
            <span class="thisPage" style="font-size:7px">(Midnight)<br/>
            </span>
            <span class="thisPage" style=" position:relative; font-weight:lighter">
            <a style="cursor:pointer; text-align:center; width:109px" onmouseover="showspLegend('spLegend')" onmouseout="showspLegend()">Legend</a><img id="spLegend" style="display:none" src="./ajax-images/heavensLegend.png" alt="Legend"/>
          </span>
        <?php 
            
?>

      <> 
<!-- End of Gerry's Piechart Code -->
« Last Edit: June 27, 2023, 12:00:19 PM by chrisgrainger »

Offline kplew

  • Member
  • *
  • Posts: 43
    • Plew Farm Weather
Re: Undefined variable after Saratoga update
« Reply #1 on: December 14, 2024, 01:31:22 PM »
Chris- Did you ever get this sorted? I have the same issue.

Thanks

Offline chrisgrainger

  • Contributor
  • ***
  • Posts: 127
    • Top of The Rideau
Re: Undefined variable after Saratoga update
« Reply #2 on: December 14, 2024, 02:06:31 PM »
G'day,


I did "solve" the issue.  I am not a PHP coder by any stretch, and this is probably not best practice but the warnings did go away.  I'm displaying the Sunlight Hours piechart in my sidebar as can be seen at RideauWx .  So, at the top of menubar.php, after the initial comments, I added


Code: [Select]
<?php error_reporting (E_ALL E_NOTICE); ?>

Problem "solved".

I started getting the same error in ec-forecast.php as well.  Added the same code to the top of that file and fixed the display error.  From my reading online, it has something to do with the way error checking changed between PHP 7.4 and PHP 8.0.  It is more robust in ver 8.0.


Hope that helps.


Chris
« Last Edit: December 14, 2024, 02:12:23 PM by chrisgrainger »

 

anything