Jump to content

my stepping through an array using "next()" is not working.


silverglade

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.