Jump to content

session variable as array element for another session variable?


Richard_Hollenbeck
Go to solution Solved by ignace,

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.

 

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.