Author Topic: Help  (Read 272 times)

0 Members and 1 Guest are viewing this topic.

Offline DaculaWeather

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 3218
    • North Georgia Weather
Help
« on: June 30, 2025, 08:24:32 AM »
I have a script that use to work, but since my PHP has changed multiple times since it did work, I'm pretty sure that the problem. This script would automatically change the background image based on the season, but no longer does. Below is the script and my current php version. Any help would be greatly appreciated!

<?php

function current_season() {
       // Location of the images
       $images = array(
               "spring" => "/images/backgrounds/spring_day.jpg",
               "summer" => "/images/backgrounds/summer_day3.jpg",
               "fall"   => "/images/backgrounds/fall_day4.jpg",
               "winter" => "/images/backgrounds/winter_day.jpg",
       );

       // What is today's date - number
date_default_timezone_set("America/New York");
$day = date("z");
       //  Days of spring
       $spring_starts = date("z", strtotime("March 1"));
       $spring_ends   = date("z", strtotime("May 31"));

       //  Days of summer
       $summer_starts = date("z", strtotime("June 1"));
       $summer_ends   = date("z", strtotime("August 31"));

       //  Days of autumn
       $autumn_starts = date("z", strtotime("September 1"));
       $autumn_ends   = date("z", strtotime("November 30"));
      
      //  Days of winter
       $winter_starts = date("z", strtotime("December 1"));
      $winter_ends   = date("z", strtotime("February 28"));


       //  If $day is between the days of spring, summer, fall, and winter
       if(     $day >= $spring_starts && $day <= $spring_ends ) :
               $season = "spring";
       elseif( $day >= $summer_starts && $day <= $summer_ends ) :
               $season = "summer";
       elseif( $day >= $autumn_starts && $day <= $autumn_ends ) :
               $season = "fall";
       elseif( $day >= $winter_starts && $day <= $winter_ends ) :
               $season = "winter";
       endif;

    $image_path = $images[$season];
    echo $image_path;
           
}

?>

 [ You are not allowed to view attachments ]


Offline broadstairs

  • Forecaster
  • *****
  • Posts: 1130
Re: Help
« Reply #1 on: June 30, 2025, 08:36:06 AM »
Well if your script has any error in it your logs will show the error message. Take a look at your error logs on the server to see if it shows anything, this will be the fastest way to a resolution if it does show an error.

Stuart
Ecowitt GW1003 with ultrasonic wind gauge, lightning sensor and PM2.5 sensor with Personal Weather Tablet as a console.

Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 2082
    • My PWS at Leuven Belgium Europe
Re: Help
« Reply #2 on: June 30, 2025, 08:41:53 AM »
Check your index.php

There are   )" charactes missing after the correct summer image.
Code: [Select]
</head>

<body style="background-image: url(/images/backgrounds/summer_day3.jpg;>

<div id="div_wrap">

You can see in the image that the missing characters  mix up the link of the image
« Last Edit: June 30, 2025, 08:45:16 AM by wvdkuil »

Offline Jasiu / JJ

  • Forecaster
  • *****
  • Posts: 1030
    • LexMAWeather
Re: Help
« Reply #3 on: June 30, 2025, 09:03:44 AM »
Might want to take a look at your validation errors. You may have additional issues.

https://validator.w3.org/nu/?doc=https%3A%2F%2Fwww.daculaweather.com%2F

https://lexmaweather.info
Mastodon: @LexMAWeather@toot.community
Bluesky: @LexMAWeather.toot.community.ap.brid.gy

Offline DaculaWeather

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 3218
    • North Georgia Weather
Re: Help
« Reply #4 on: June 30, 2025, 09:39:29 AM »
Thanks, that was it.

I did a search and replace on 400+ pages, just haven't uploaded all of them yet. :-)


Offline DaculaWeather

  • WxElement panel
  • Forecaster
  • *****
  • Posts: 3218
    • North Georgia Weather
Re: Help
« Reply #5 on: June 30, 2025, 04:24:14 PM »
Thanks, that was it.

I did a search and replace on 400+ pages, just haven't uploaded all of them yet. :-)
Yea, most of those have been fixed, the errors are cached right now.

Years ago, you added a / at the end of things, and now no. All of those 400+ pages were built from scratch, no templates used.

 

anything