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
https://forums.phpfreaks.com/topic/230159-help-image-array-not-working/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.