john010117 Posted November 28, 2006 Share Posted November 28, 2006 I have used one of your scripts called "Random Image Rotator". It's supposed to display a random image every time you load up the page. I've inserted the code into a file named "rotate.php" and have changed the necessary variables to make it work. All my images are in the "images" folder, and I haven't placed this file in a folder. Here's the code for it:[code]<?php// Change the folder name to your one in the line below$folder = "images"; srand( time() );if ($directory = @opendir($folder)) {while (($image = readdir($directory)) !== false) {if ( eregi( '.(jpg|gif)$', $image ) ) { $images[] = $image; }} closedir($directory);}$image = $images[rand() % sizeof( $images )];if ( eregi( '.jpg$', $image ) ) {header( "Content-Type: image/jpeg" );} else {header( "Content-Type: image/gif" );}header( "Content-Length: " . filesize( $folder."/".$image ) );readfile( $folder."/".$image );?>[/code]Can anybody detect what's wrong with this code? Note that the code didn't say anything about needing a MySQL database (which I don't have; I'm on a free hosting account).If you must see the file which I've placed this code into, [url=http://free.hostultra.com/~halotrilogy/rotate.php]here it is[/url].Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/28684-php-image-rotator-help/ Share on other sites More sharing options...
Caesar Posted November 28, 2006 Share Posted November 28, 2006 Does your hosting support GD Library? And if so, make sure that it has support for the image type you're using.Upload a file to your host and call it info.php....with the following code:[code]<?phpphpinfo();?>[/code]Then bring up that page in your browser and check for GD Library. Quote Link to comment https://forums.phpfreaks.com/topic/28684-php-image-rotator-help/#findComment-131281 Share on other sites More sharing options...
john010117 Posted November 28, 2006 Author Share Posted November 28, 2006 I've saved the code like you told me to do, but I didn't see anything about GD Library... if you want to double-check, [url=http://free.hostultra.com/~halotrilogy/info.php]here's the link[/url].PS: The code author said you only needed PHP, and nothing else. Quote Link to comment https://forums.phpfreaks.com/topic/28684-php-image-rotator-help/#findComment-131286 Share on other sites More sharing options...
corbin Posted November 28, 2006 Share Posted November 28, 2006 The code posted doesnt need the GD lib. and pretty sure his host doesnt support it ><.Just of curiosity where'd that code come from? It looks familiar, not sure why though...Edit:Hmm just tested the posted script on my local server... Worked perfect. On the page you posted a link to some javascript tag is appearing and I think thats messin with your headers and makin it output the page as text... Does your webhost automatically append that script to everypage? Quote Link to comment https://forums.phpfreaks.com/topic/28684-php-image-rotator-help/#findComment-131295 Share on other sites More sharing options...
Caesar Posted November 28, 2006 Share Posted November 28, 2006 [quote author=corbin link=topic=116528.msg474823#msg474823 date=1164677262]Edit:Hmm just tested the posted script on my local server... Worked perfect. On the page you posted a link to some javascript tag is appearing and I think thats messin with your headers and makin it output the page as text... Does your webhost automatically append that script to everypage?[/quote]Noticed the same thing. A lot of free hosts do this. Probably a popup/ad being called via Javascript. Quote Link to comment https://forums.phpfreaks.com/topic/28684-php-image-rotator-help/#findComment-131305 Share on other sites More sharing options...
john010117 Posted November 28, 2006 Author Share Posted November 28, 2006 I [i]do[/i] have 1 popup ad... is that why it isn't working? Quote Link to comment https://forums.phpfreaks.com/topic/28684-php-image-rotator-help/#findComment-131307 Share on other sites More sharing options...
corbin Posted November 28, 2006 Share Posted November 28, 2006 Plainly put - yes.Unless there is some way to get them to disable the popup on that page that script will not work.An alternate method would be to generate the image name then call to it via a basic <img> tag... Quote Link to comment https://forums.phpfreaks.com/topic/28684-php-image-rotator-help/#findComment-131318 Share on other sites More sharing options...
john0117 Posted November 28, 2006 Share Posted November 28, 2006 Ok, thank you. I have just moved over to a different host with NO POPUP ADS. It's working perfectly. Thank you all very much. Quote Link to comment https://forums.phpfreaks.com/topic/28684-php-image-rotator-help/#findComment-131322 Share on other sites More sharing options...
corbin Posted November 28, 2006 Share Posted November 28, 2006 Just of curiosity is it a free host with out pop-ups? Cause if it is I would like to know what site it is :P Quote Link to comment https://forums.phpfreaks.com/topic/28684-php-image-rotator-help/#findComment-131367 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.