• Log in or sign up for an account here: https://www.sythe.org/login

Radio banner rotation script needed.

Adamskii

Newcomer
Joined
Mar 2, 2009
Sythe Gold
0
Messages
12
Location
The Internet.
Hey guys,
Just a quick question, is it possible to create a script that changes a banner image every hour? I'm looking at something for my radio station, but can't get this script to work. What I've got at the moment is:
PHP:
<?php
$time = date('H');
$imgtype = "png";
if($time = 21) {
$img = "adam";
}
else {
$img = "offline";
}
echo date('H:m s');
echo("$img");
?>
Bearing in mind my server is currently GMT-1 so its 21:45 now on there, its permenantly showing the offline image. The echo sections at the bottom are telling me it should be working, but its not.

Just wondering if anyone could guide me as to what to do about this script, its got to be able to handle a few DJs, and manage to keep updated with each hourly show.

Thanks.

Edit:
For the image to display, there is a <img> tag on the page, with a php echo of the $img, So it does actually show up on pages.
 
You could do it the real lame way and just put a if-echo for every image that activates when the time is right.

Otherwise you should use javascript.
 
Member of the Month Winner
Sythe's 10th Anniversary
Couldn't you just get the time using the PHP date() function, and display an image according to what time it is?
 
Tried that, but for some reason, the website caches the image nomatter what I try. I've tried all sorts of things to clear the memory of the image, but they don't want to work.
 
Member of the Month Winner
Sythe's 10th Anniversary
Tried that, but for some reason, the website caches the image nomatter what I try. I've tried all sorts of things to clear the memory of the image, but they don't want to work.
It is a perfectly logical method. If it doesn't work, it's likely your code, or server time.
 
Tested on my local xampp install, but this should work nonetheless:

PHP:
<?php
$date = date(H);
$img = "";
if ($Date <= 10) {
	$img = "<img src='images/adam.png' />";
}
else if($Date <= 14) {
	$img = "<img src='images/offline.png' />";
}
else {
	$img = "<img src='images/other.png' />";
}
echo $img;
?>

if you need an explanation... -_-
 
Ok, I've installed that script to a page, and its still coming up with the same error for me. I've left the times as set, and the server time is about one hour out compared to my timezone, and its refusing to show either of the set offline images. I'll post the link to you guys, but for me its still showing up as the one image, and doesn't change when the configuration does.
Link

Can you guys please tell me what you get for this, as I don't know if its my machine caching the file, or whether my host is just generally buggered.

Thanks.

Edit: Found a quick and easy fix for this.

Whilst browsing W3Schools for a PHP fix, I found this in the Javascript section, thought I'd post it just in case anyone needs the script:
var d = new Date();
var time = d.getHours();
if (time == 20)
{
document.write("<img src='images/adam.png' border='0' />");
}
else
{
document.write("<img src='images/offline.png' border='0' />");
}
This script is currently working without fail, so I'm hoping for the best in the future with it.

Thanks to all those who helped me work this one out.

Problem Solved. Thread Can Be Closed.
 
Ok, I've installed that script to a page, and its still coming up with the same error for me. I've left the times as set, and the server time is about one hour out compared to my timezone, and its refusing to show either of the set offline images. I'll post the link to you guys, but for me its still showing up as the one image, and doesn't change when the configuration does.
Link

Can you guys please tell me what you get for this, as I don't know if its my machine caching the file, or whether my host is just generally buggered.

Thanks.

Edit: Found a quick and easy fix for this.

Whilst browsing W3Schools for a PHP fix, I found this in the Javascript section, thought I'd post it just in case anyone needs the script:

This script is currently working without fail, so I'm hoping for the best in the future with it.

Thanks to all those who helped me work this one out.

Problem Solved. Thread Can Be Closed.

so when someone comes to your site without javscript, they get nothing? And the javascript solution is client-side meaning it is according to the user's time settings, not the servers with the php, did you at any chance echo the output times from the server and matched that to the script?
 
so when someone comes to your site without javscript, they get nothing?
Its just a small box banner, the website still looks complete without it. People without Javascript are advised to get it, but its only a school radio, so they're not vital, just helpful.

The javascript solution is client-side meaning it is according to the user's time settings, not the servers with the php, did you at any chance echo the output times from the server and matched that to the script?
Like I said, its only a small school radio, so most of our listeners are in the same timezone.
 
Its just a small box banner, the website still looks complete without it. People without Javascript are advised to get it, but its only a school radio, so they're not vital, just helpful.


Like I said, its only a small school radio, so most of our listeners are in the same timezone.

You could put something like

Code:
<noscript>JavaScript is required for this part of the site!</noscript>
 
Member of the Month Winner
Sythe's 10th Anniversary
You could put something like

Code:
<noscript>JavaScript is required for this part of the site!</noscript>
Or he could find out why his PHP isn't working. I'm starting to think perhaps his server doesn't have the correct Apache or IIS PHP modules installed.
 
Or he could find out why his PHP isn't working. I'm starting to think perhaps his server doesn't have the correct Apache or IIS PHP modules installed.

Option one is easier, lol.
 
Member of the Month Winner
Sythe's 10th Anniversary
Option one is easier, lol.
Option one being "Find out why PHP isn't working", or use his disgusting Javascript method?

Finding out why PHP doesn't work isn't hard. If anything it'd probably be easier to diagnose than implementing a sloppy block of JS.
 
I've already added a
Code:
<noscript></noscript>
But I've just left it blank being as they're not exactly missing out on much.

And they probably have got a real bad server because its a free web host. They've managed to block most php expressions for 'security reasons' which is why I was trying to find a way round it.
 
Runescape Gamblingrunescape gambling
Back
Top