1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Random Image Selector.

Discussion in 'Programming' started by andymayo, Jun 17, 2008.

  1. #1
    Right well lets say i make about 10 banners for my site.. all with suttle differences.. and when the page loads i want one to load randomly so the user sees a veriaty of the images randomly...

    I know where the image is i want to replace and im assuming i replace that with a script of which contains the images i have..

    If there isnt anything free available then i am willing to pay a resonable ammount. I Have a few features i want to be adding to my site (they are posted on DP) and i need to get these done ASAP.

    cheers people look faward to hearing off you.
     
    andymayo, Jun 17, 2008 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    There is absolutely no need to pay me (atleast) for this 2 minutes reply :)


    save following as random_mage.php


    save following as test_script.php

    Now upload, both files, and browe test_script.php


    I hope it helps.

    regards
     
    Vooler, Jun 17, 2008 IP
    TheVccMatey likes this.
  3. andymayo

    andymayo Guest

    Messages:
    652
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You sexy peon, ill go try it now. and i assume u mean random image not mage :p
     
    andymayo, Jun 17, 2008 IP
  4. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #4
    IMPORTANT: When saving as php file in notepad, there must not be even a single character before <? and after ?> otherwise random_mage.php wont work correctly. And may result an error 'Header already sent'.

    regards
     
    Vooler, Jun 17, 2008 IP
  5. andymayo

    andymayo Guest

    Messages:
    652
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I have created the two pages and here is the code within them.


    random_image.php =

    test script =

    when the page is opened i get the little red box indicating an image error... any help appreciated.

    Note that is the whole pages code selected.
     
    andymayo, Jun 17, 2008 IP
    TheVccMatey likes this.
  6. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #6
    open the random_image.php directly and if possible please show me the link I can diagnose myself

    Also "http://www.xninelivesx.com/images/banner.gif", is the last entry which must no have a comma ',' at the end.

    regards
     
    Vooler, Jun 17, 2008 IP
  7. andymayo

    andymayo Guest

    Messages:
    652
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #7
    andymayo, Jun 17, 2008 IP
  8. TheVccMatey

    TheVccMatey Peon

    Messages:
    5,346
    Likes Received:
    208
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks for the replies.. Reps added.
     
    TheVccMatey, Jun 17, 2008 IP
  9. andymayo

    andymayo Guest

    Messages:
    652
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Replies to what? thats your 1st post here. Cheers for the rep though.
     
    andymayo, Jun 17, 2008 IP
  10. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #10
    You definitely have left a blank character anywhere either before <?

    or after
    header("Location: $random_image");
    ?>

    Which is resulting function header not being executed and header not being sent ot browser.

    Second cause may be the image url is not valid.

    Lets do it in one script: (include followng in your html page anywhere)
    in this script you do not need to worry about space characters. I was actualy trying ot provide you a more generic way.

    regards
     
    Vooler, Jun 17, 2008 IP
  11. chenna

    chenna Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    hi
    if u want i will do it for u plz reply to me
    abhi
     
    chenna, Jun 18, 2008 IP
  12. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #12
    Sorry My mistake in code, I was requesting numebr as image url

    Following code is 100% file, save it in file and run it


    regards
     
    Vooler, Jun 18, 2008 IP
  13. andymayo

    andymayo Guest

    Messages:
    652
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #13
    andymayo, Jun 18, 2008 IP
  14. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #14
    The last version I provided does all the job itself, so there is no need of second script. http://www.xninelivesx.com/random_image.php is sufficient. You can add HTML code to it before <? and after ?> easily in notepad.

    regards
     
    Vooler, Jun 18, 2008 IP
  15. andymayo

    andymayo Guest

    Messages:
    652
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #15
    ok thats great..so i include that script on the pages i need yes?.. isnt there a way to use it like an include? im shit at php btw :p
     
    andymayo, Jun 19, 2008 IP
  16. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #16
    You can use both.
    I have attached a file random_image.php, upload this one without modifying (IMPORTANT upload in BINARY mode not ASCII in your FTP program)

    Then put following code in your html page anywhere you wish to load random image without worrying about space characters or anything
    Besides, try checking in possible browsers like IE, FireFox, Opera, Safari etc.

    I hope you don't pull your hair now :).

    regards
     

    Attached Files:

    Vooler, Jun 19, 2008 IP
    andymayo likes this.
  17. gorantla

    gorantla Peon

    Messages:
    115
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    stil u need this?
    i will do it
    abhi
     
    gorantla, Jun 26, 2008 IP
  18. andymayo

    andymayo Guest

    Messages:
    652
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #18
    yes i do i need it to merge in V bullitin also
     
    andymayo, Jun 26, 2008 IP
  19. andymayo

    andymayo Guest

    Messages:
    652
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #19
    vooler so far you have been great and im glad to see your post count shoot up... but in my v-bullitin forum.. i wanrt it at the top.. any advice?
     
    andymayo, Jul 8, 2008 IP
  20. furca

    furca Well-Known Member

    Messages:
    1,478
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    125
    #20
    1) Go to admin control panel
    2) Go to STYLES & TEMPLATES --> Style Manager
    3) Select the desired template, then click the dropdown box then click EDIT TEMPLATES.
    4) Edit the appropraite template. For under the navigation simply click NAVBAR and add the script to the bottom of the code.
     
    furca, Jul 8, 2008 IP