Jump to content

session variable as array element for another session variable?


Richard_Hollenbeck

Recommended Posts

In my quiz program, I'm getting the following error:
 

PHP Parse error:  syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /~mypath~/quiz.php on line 61

 


I have two session variables:
question_ids is an array, and
question_pointer is an integer that is supposed to tell the program which question_ids to display.  

After each question, the question_pointer will get incremented and the next question will be displayed.

I get confused with all the single quotes (apostrophes) and double quotes (quotation marks.)

Here is the problematic line 61:

<?php
// ... (other code ) ...
 print $_SESSION["question_ids[$_SESSION['question_pointer']"]; // line 61
// ... (other code ) ...
?>

Since learning about session variables and especially arrays as session variables, I have had a problem visualizing how to write the code to place the session variable as the array element for another session variable.  How could I do this that would work?  Thanks.

 

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.