Jump to content

HELP - Image array not working


drums

Recommended Posts

I asked a question in another thread about making this script work in multiple instances but now I can't even get it to work!

<?php 
$cpics = array (
       "images/sidebar/party1.jpg",
       "images/sidebar/party2.jpg",
       "images/sidebar/party3.jpg"
);
$index = rand(0, 2);
$cbanner = $cpics[$index];
?>

 

And in the http://do-rightweb.com/1-test.php test page

<img src="$cbanner">

 

Thanks very much for your help.

Link to comment
Share on other sites

I think all you need to do is wrap your $cbanner variable in PHP tags, so the server can parse it.

 

<img src="<?php echo $cbanner; ?>">

 

Of course, this is speculation.  You didn't give a whole lot of code from your HTML page.  I make this decision based on the source code of your linked page.

Link to comment
Share on other sites

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.