$_SESSION $_POST

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Quinonez

    $_SESSION $_POST

    i set up a multipage form about a month ago using Sessions everything
    worked well and i moved forward with working on other pages i just
    checked the form to make sure it is all working properly and its giving
    me an error:

    Warning: Invalid argument supplied for foreach() in
    /home/mastersc/public_html/testthis.php on line 24

    this is the code:

    <?
    ksort($_SESSION );
    foreach ($_SESSION as $page=>$_POST)
    {
    echo "<div class=\"h3\">$p age</div><br>";
    foreach ($_POST as $field=>$value) <--this would be line 24-->
    {
    echo "$field: $value<br>";
    }
    }
    ?>

    any suggestions?

  • Kevin

    #2
    Re: $_SESSION $_POST

    Try doing a var_dump or print_r of $_SESSION before your for loop.

    I suspect that there's a key => value pair where the value isn't an array.

    - Kevin

    "Quinonez" <quinonez@gmail .com> wrote in message
    news:1105480688 .597766.43520@c 13g2000cwb.goog legroups.com...[color=blue]
    >i set up a multipage form about a month ago using Sessions everything
    > worked well and i moved forward with working on other pages i just
    > checked the form to make sure it is all working properly and its giving
    > me an error:
    >
    > Warning: Invalid argument supplied for foreach() in
    > /home/mastersc/public_html/testthis.php on line 24
    >
    > this is the code:
    >
    > <?
    > ksort($_SESSION );
    > foreach ($_SESSION as $page=>$_POST)
    > {
    > echo "<div class=\"h3\">$p age</div><br>";
    > foreach ($_POST as $field=>$value) <--this would be line 24-->
    > {
    > echo "$field: $value<br>";
    > }
    > }
    > ?>
    >
    > any suggestions?
    >[/color]


    Comment

    • Andy Hassall

      #3
      Re: $_SESSION $_POST

      On 11 Jan 2005 13:58:08 -0800, "Quinonez" <quinonez@gmail .com> wrote:
      [color=blue]
      >i set up a multipage form about a month ago using Sessions everything
      >worked well and i moved forward with working on other pages i just
      >checked the form to make sure it is all working properly and its giving
      >me an error:
      >
      >Warning: Invalid argument supplied for foreach() in
      >/home/mastersc/public_html/testthis.php on line 24
      >
      >this is the code:
      >
      ><?
      >ksort($_SESSIO N);[/color]

      Is session.auto_st art turned on? Shouldn't you call session_start() first?
      [color=blue]
      >foreach ($_SESSION as $page=>$_POST)[/color]

      This seems a little odd - you're overwriting the superglobal variable $_POST
      with the contents of the session array values?
      [color=blue]
      >{
      >echo "<div class=\"h3\">$p age</div><br>";
      >foreach ($_POST as $field=>$value) <--this would be line 24-->[/color]

      The error basically implies $_POST is not an array at this point. Dump it out
      with var_dump/print_r, along with $_SESSION from earlier.
      [color=blue]
      >{
      > echo "$field: $value<br>";
      > }
      >}
      >?>
      >
      >any suggestions?[/color]

      --
      Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
      <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

      Comment

      Working...