drums Posted March 10, 2011 Share Posted March 10, 2011 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 More sharing options...
jcbones Posted March 10, 2011 Share Posted March 10, 2011 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 https://forums.phpfreaks.com/topic/230159-help-image-array-not-working/#findComment-1185308 Share on other sites More sharing options...
MadLittleMods Posted March 10, 2011 Share Posted March 10, 2011 Also if you are in an echo you could just do: (are you in the same scope as well? - your array on the same page) <img src="', $cbanner ,'"> Link to comment https://forums.phpfreaks.com/topic/230159-help-image-array-not-working/#findComment-1185319 Share on other sites More sharing options...
drums Posted March 10, 2011 Author Share Posted March 10, 2011 jcbones, thanks, ECHO was what I was missing! MadLittleMods, I tried that but it didn't work. Link to comment https://forums.phpfreaks.com/topic/230159-help-image-array-not-working/#findComment-1185397 Share on other sites More sharing options...
drums Posted March 10, 2011 Author Share Posted March 10, 2011 Link to comment https://forums.phpfreaks.com/topic/230159-help-image-array-not-working/#findComment-1185418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.