-1

can anyone explain this to me?:

if (isset($_SESSION['pack'])){
   if (is_array($_SESSION['pack'])){
      foreach ($_SESSION['pack'] as $pack){
         //code
      }
   }
}

i get:

Warning: Invalid argument supplied for foreach()

and if i do

die(var_dump($_SESSION['pack']));

i get

array(1) { [0]=> string(2) "16" } 

i'm really going bonkers with this one, i need it ready for tonight and i'm stuck with this...

Thanks

3
  • did u try to run in for loop ? Commented Mar 27, 2011 at 19:22
  • 5
    I'm not sure, but if you have register_globals enabled, $_SESSION['pack'] will be the same as $pack. That might produce the wired results. Either make sure register_globals is disabled, or rename $pack to something else. Commented Mar 27, 2011 at 19:24
  • 1
    @fab You might want to make your comment an answer :) Commented Mar 27, 2011 at 19:48

1 Answer 1

3

Regarding the line

foreach ($_SESSION['pack'] as $pack){...

If you have register_globals enabled, $_SESSION['pack'] will be the same as $pack. That might produce the weird results. Either make sure register_globals is disabled, or rename $pack to something else.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.