silverglade Posted August 4, 2010 Share Posted August 4, 2010 Hi, I'm trying to step through this array when the "further " button is pressed and it should change the image in the div when I echo it out. I'm getting the following error Fatal error: Only variables can be passed by reference in C:\wamp\www\SUN_DRAGON_GAME\gamestart.php on line 224 here is the array $currentLocation = array ( 'teardrop_ocean_bg' => array ( 'level_1'=>"<img src='<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>'", 'level_2'=>"<img src='<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>'", 'level_3'=>"<img src='<img src='sundragon_environments/ocean/ocean1_FRAME3.jpg'/>'", 'level_4'=>"<img src='<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>'", 'level_5'=>"<img src='<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>'" ) ); and here is the code I'm using to try to step through the "teardrop_ocean" array. $currentLocation='teardrop_ocean';//declare variables/this is set after we click on image map link for teardrop $currentLocArray=''; //the following is set after we click on the teardrop ocean link on the image map . //check if the current location is teardrop ocean, if so, set current loc array to the teardrop ocean bg array. if($currentLocation=='teardrop_ocean'&& !empty($_POST['further'])) { $currentLocArray=$currentLocation['teardrop_ocean_bg']; } //if in teardrop, and further is pressed, go to next element, which is a new img src background. if($currentLocArray==$currentLocation['teardrop_ocean_bg']&& !empty($_POST['further'])) { next($currentLocation['teardrop_ocean_bg']); } any help greatly appreciated. Thanks. Derek Quote Link to comment Share on other sites More sharing options...
silverglade Posted August 4, 2010 Author Share Posted August 4, 2010 I changed the code. This just shows up a black div. Not the image. $currentLocation='teardrop_ocean';//declare variables/this is set after we click on image map link for teardrop $currentLocArray=''; //the following is set after we click on the teardrop ocean link on the image map . //check if the current location is teardrop ocean, if so, set current loc array to the teardrop ocean bg array. if($currentLocation=='teardrop_ocean'&& !empty($_POST['further'])) { $echoLocation=next($teardrop_ocean_bg); } I output $echoLocation later on inside the div. Quote Link to comment Share on other sites More sharing options...
AtlasC1 Posted August 4, 2010 Share Posted August 4, 2010 What's the deal with this?: <img src='<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/> You have <img src='<img src=' which is going to cause problems almost immediately. Should it not just be: "<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>" ? Also, another tidbit of information: In HTML the <img> tag has no end tag, but in XHTML the <img> tag must have a closing tag. Let us know if that fixes the problem! -jm Quote Link to comment Share on other sites More sharing options...
silverglade Posted August 4, 2010 Author Share Posted August 4, 2010 awesome thanks very much! wow I can't believe I made that mistake. Also, when I run it now it only goes to background 2. and doesn't show background 1. Any more help greatly appreciated. Thanks for pointing that out. Derek Quote Link to comment 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.