Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: IE Problem

  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts

    IE Problem

    Hi,

    My friend helped me create a PHP script that randomizes picture upon refresh, but it doesn't work in Internet Explorer. How do you solve this?

    PHP (rewritten as a rotate.jpg)
    <?php
    $images=Array(
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture01.jpg",
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture02.jpg",
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture03.jpg",
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture04.jpg",
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture05.jpg",
    );
    shuffle($images);
    //header("Location: ".$images[0]);
    echo file_get_contents ($images[0]);
    ?>

    .htaccess
    <FilesMatch rotate.jpg>
    ForceType application/x-httpd-php
    </FilesMatch>


    Image: http://rappating.ismyse.com/rotate/rotate.jpg
    (Webpage, http://rappating.ismyse.com/rotate/)
    Last edited by Rapport; 07-15-2008 at 05:59 AM.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Append a random number to the url of the image.
    PHP Code:
    <?php
    $images
    =Array(
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture01.jpg?id=".rand(0,1000),
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture02.jpg?id=".rand(0,1000),
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture03.jpg?id=".rand(0,1000),
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture04.jpg?id=".rand(0,1000),
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture05.jpg?id=".rand(0,1000)
    );
    shuffle($images);
    //header("Location: ".$images[0]);
    echo file_get_contents ($images[0]);
    ?>
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    Rapport (07-16-2008)

  • #3
    New Coder
    Join Date
    Jun 2008
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I relabeled first 0's in .rand(0,1000) to 1, 2, 3, 4, 5 respectively, but the image still doesn't show up on IE7.


    Does it work on yours?
    (Recheck webpage)
    Last edited by Rapport; 07-15-2008 at 11:41 PM.

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,043
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Try adding cache control to make the page load from the site everytime instead of loading from the temp dir....

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I find that I often need both the cache control (for IE) and the random numbers (FF) for displaying images. I don't know why the FF caches it but it definitely does. Took me awhile waaaayy back to realize a t=rand() does the trick
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #6
    New Coder
    Join Date
    Jun 2008
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Fou-Lu, could you explain to me how to do that?

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Mmkay, the PHP headers need to be like so:
    PHP Code:
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past 
    You could also use a pragma for it, but the two above should be sufficient. Those are taken directly from the PHP site's header section. Since these are headers you must place them before any output to the page (echo, print, and no spaces or output before <?php). As for the image, just use what Aerospace posted, that should provide a unique image so that any attempted cache will still require looking up the image to use. The queystring part is ignored by the image so you don't need to worry about anything bad happening. Thats the best part about the browser - its easily fooled
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    Rapport (07-16-2008)

  • #8
    New Coder
    Join Date
    Jun 2008
    Posts
    20
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I feel like I'm doing something wrong...

    PHP
    <?php
    header("Cache-Control: no-cache, must-revalidate");
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    $images=Array(
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture01.jpg?id=".rand(1,1000),
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture02.jpg?id=".rand(2,1000),
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture03.jpg?id=".rand(3,1000),
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture04.jpg?id=".rand(4,1000),
    "http://i215.photobucket.com/albums/cc114/fifthcadence/Sample_Picture05.jpg?id=".rand(5,1000)
    );
    shuffle($images);
    //header("Location: ".$images[0]);
    echo file_get_contents ($images[0]);
    ?>

    Is this ok?

    ---

    EDIT

    I tested the webpage on IE on another computer, and it appears that your script works.
    My IE is probably still running on a temporary cache, which is why the webpage looks like it has a broken image.

    But that's ok. Thank you _Aerospace_Eng_, Fou-Lu.
    Last edited by Rapport; 07-16-2008 at 10:46 PM. Reason: Retesting

  • #9
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,020
    Thanks
    2
    Thanked 313 Times in 305 Posts
    Both the links you posted currently work in IE7. There appear to be about 6 different images.

    What exact symptoms do you get?
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •