Radio banner rotation script needed.

Discussion in 'Web Programming' started by Adamskii, May 7, 2009.

Radio banner rotation script needed.
  1. Unread #1 - May 7, 2009 at 5:42 PM
  2. Adamskii
    Joined:
    Mar 2, 2009
    Posts:
    12
    Referrals:
    0
    Sythe Gold:
    0

    Adamskii Newcomer

    Radio banner rotation script needed.

    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.
     
  3. Unread #2 - May 8, 2009 at 5:16 AM
  4. fighter1431
    Joined:
    Feb 21, 2007
    Posts:
    418
    Referrals:
    0
    Sythe Gold:
    0

    fighter1431 Forum Addict

    Radio banner rotation script needed.

    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.
     
  5. Unread #3 - May 8, 2009 at 2:12 PM
  6. Adamskii
    Joined:
    Mar 2, 2009
    Posts:
    12
    Referrals:
    0
    Sythe Gold:
    0

    Adamskii Newcomer

    Radio banner rotation script needed.

    Thanks. I think my web host is a bit off and saves some kind of cache, not too sure though.

    Any ideas as to what I could do based on Javascript? I've never seen the need to use it before, so any help would be greatly appreciated. :laugh:

    Thanks
     
  7. Unread #4 - May 8, 2009 at 4:41 PM
  8. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Radio banner rotation script needed.

    Couldn't you just get the time using the PHP date() function, and display an image according to what time it is?
     
  9. Unread #5 - May 8, 2009 at 4:56 PM
  10. Adamskii
    Joined:
    Mar 2, 2009
    Posts:
    12
    Referrals:
    0
    Sythe Gold:
    0

    Adamskii Newcomer

    Radio banner rotation script needed.

    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.
     
  11. Unread #6 - May 8, 2009 at 7:41 PM
  12. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Radio banner rotation script needed.

    It is a perfectly logical method. If it doesn't work, it's likely your code, or server time.
     
  13. Unread #7 - May 9, 2009 at 8:47 PM
  14. TDD
    Joined:
    Nov 20, 2005
    Posts:
    3,191
    Referrals:
    2
    Sythe Gold:
    0

    TDD Web Design Expert
    Do Not Trade

    Radio banner rotation script needed.

    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... -_-
     
  15. Unread #8 - May 10, 2009 at 4:56 PM
  16. Adamskii
    Joined:
    Mar 2, 2009
    Posts:
    12
    Referrals:
    0
    Sythe Gold:
    0

    Adamskii Newcomer

    Radio banner rotation script needed.

    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.
     
  17. Unread #9 - May 11, 2009 at 3:22 AM
  18. TDD
    Joined:
    Nov 20, 2005
    Posts:
    3,191
    Referrals:
    2
    Sythe Gold:
    0

    TDD Web Design Expert
    Do Not Trade

    Radio banner rotation script needed.

    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?
     
  19. Unread #10 - May 12, 2009 at 10:42 AM
  20. Adamskii
    Joined:
    Mar 2, 2009
    Posts:
    12
    Referrals:
    0
    Sythe Gold:
    0

    Adamskii Newcomer

    Radio banner rotation script needed.

    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.
     
  21. Unread #11 - May 12, 2009 at 11:34 AM
  22. i am java
    Joined:
    Apr 9, 2008
    Posts:
    231
    Referrals:
    0
    Sythe Gold:
    0

    i am java Active Member

    Radio banner rotation script needed.

    You could put something like

    Code:
    <noscript>JavaScript is required for this part of the site!</noscript>
     
  23. Unread #12 - May 12, 2009 at 5:52 PM
  24. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Radio banner rotation script needed.

    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.
     
  25. Unread #13 - May 12, 2009 at 7:36 PM
  26. i am java
    Joined:
    Apr 9, 2008
    Posts:
    231
    Referrals:
    0
    Sythe Gold:
    0

    i am java Active Member

    Radio banner rotation script needed.

    Option one is easier, lol.
     
  27. Unread #14 - May 13, 2009 at 2:10 AM
  28. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Radio banner rotation script needed.

    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.
     
  29. Unread #15 - May 13, 2009 at 2:22 AM
  30. Adamskii
    Joined:
    Mar 2, 2009
    Posts:
    12
    Referrals:
    0
    Sythe Gold:
    0

    Adamskii Newcomer

    Radio banner rotation script needed.

    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.
     
< Word Extractor. | Need help with some PHP/MYSQL code >

Users viewing this thread
1 guest


 
 
Adblock breaks this site