Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/205786-need-help-with-a-rotating-banner-script/
Share on other sites

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'

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.

 

Sorry, but I do not know what else to say :confused:. 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.

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'>

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.