drums Posted June 24, 2010 Share Posted June 24, 2010 I have a script I haven't used in a couple years that I want to use on a new site but can't seem to get it working. I have the code below before the </head> tag: <? $hpics = array ( "images/top-main.gif", "images/top-main2.gif", "images/top-main3.gif", "images/top-main4.gif", "images/top-main5.gif", ); $index = rand(0, 4); $hbanner = $hpics[$index]; ?> And then in the body I put: <img src='$hbanner' width='723' height='306' alt='Center 4 IVF' border='0'> to try to get it to work but no show. So I thought maybe I need to make sure the server is parsing PHP therough html with .hataccess but still, no show. Ultimately I want it to go in as a background image and think this should work but would appreciate anyone pointing out any possible issues: <div id="top-main" style="background:url($hbanner) no-repeat"> So hopefully someone can sniff this out and tell me what I'm forgetting/doing wrong. Thanks very much for your help! Quote Link to comment https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/ Share on other sites More sharing options...
premiso Posted June 24, 2010 Share Posted June 24, 2010 <img src='<?php echo $hbanner; ?>' width='723' height='306' alt='Center 4 IVF' border='0'> Would be the proper way to echo a variable in the html body. Quote Link to comment https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/#findComment-1076905 Share on other sites More sharing options...
drums Posted June 25, 2010 Author Share Posted June 25, 2010 I tried that but still, nothing. Quote Link to comment https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/#findComment-1076959 Share on other sites More sharing options...
pengu Posted June 25, 2010 Share Posted June 25, 2010 I tried that but still, nothing. You should have a box with a red 'x' in it where the image is supposed to be. Check the properties of that and make sure it's pointing to the correct path. Really depends how your folders are setup, like if this script is in a folder called functions for example and your trying to get the 'image' folder which is back in the root directory that's not going to work. You'd have to go '../images/bla.jpg' Quote Link to comment https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/#findComment-1076971 Share on other sites More sharing options...
drums Posted June 25, 2010 Author Share Posted June 25, 2010 Thnks but it is not pathing. I do have the images in an images folder and I account for it in the initial JS. Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/#findComment-1077316 Share on other sites More sharing options...
premiso Posted June 25, 2010 Share Posted June 25, 2010 You have to provide us with better feed back rather than: "I tried but still not working" How are we suppose to help debug something we cannot see? What is the source code of the page the images are being echo'ed on? Is the img tag getting structured properly? Is that img code I posted above in the same php script (or a script that accessed via include?) Too many unknown variables for us to give you accurate further help. Quote Link to comment https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/#findComment-1077319 Share on other sites More sharing options...
drums Posted June 25, 2010 Author Share Posted June 25, 2010 Sorry, but I do not know what else to say . I provided the code and the images are not displaying. I still have not published the site but looking at the code is moot since it's PHP but if you want to see it go here http://do-rightweb.com/fertility/ And on line 39 you will see the code: <div id="top-main"> <img src='<?php echo $hbanner; ?>' width='723' height='306' alt='Center 4 IVF' border='0'> <p class="top-main">:: (201) 666-4200 ::</p> I get the alt tag and a broken image marker when I use <img src='<?php echo $hbanner; ?>' width='723' height='306' alt='Center 4 IVF' border='0'> Thanks very much for your help/response. Quote Link to comment https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/#findComment-1077367 Share on other sites More sharing options...
hcdarkmage Posted June 25, 2010 Share Posted June 25, 2010 here is a piece of code that helped someone else with a similar problem: $pic[array_rand($pic)] Just modify it to your needs: $hbanner[array_rand($hpics)] <img src='<?php echo $hbanner; ?>' width='723' height='306' alt='Center 4 IVF' border='0'> Quote Link to comment https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/#findComment-1077372 Share on other sites More sharing options...
drums Posted June 25, 2010 Author Share Posted June 25, 2010 Still getting the broken image thingy Quote Link to comment https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/#findComment-1077383 Share on other sites More sharing options...
hcdarkmage Posted June 25, 2010 Share Posted June 25, 2010 Check to make sure that the path to your images works. Also make sure that the images are in the proper folder that you are calling. If you are using Firefox, lookinto a little addon called firebug. It can help you see if your paths are right. Quote Link to comment https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/#findComment-1077387 Share on other sites More sharing options...
drums Posted June 25, 2010 Author Share Posted June 25, 2010 Thanks, I know, it seems like it is pathing but even with the firebug it just shows the PHP Echo and not the path or anything. Quote Link to comment https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/#findComment-1077392 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.