PHP session troubles

Discussion in 'OT Technology' started by ge0, Nov 9, 2007.

  1. ge0

    ge0 New Member

    Joined:
    Oct 31, 2005
    Messages:
    8,398
    Likes Received:
    0
    Location:
    JERSEY
    Well, I got a new issue... am I even allowed to do this?
    Code:
    <?php echo "
    <script language='javascript' type='text/javascript'>
    <!--
     function FormCheck(form)
      {
     
                      var orv = form.qty.value;
                      var rowNum = form.rowNum.value;
                      ".$rowNum." = rowNum;
                     document.getElementById('qty').value = orv;
                     ".$_SESSION["$tarray[$rowNum][0][2]"]."    
             }
     
    -->   
    </script>
    "; ?>
    
    I am trying to grab a value from the form with javascript and update the session variable with it. Any reason why its not letting me do that and giving me this error..

    Notice: Undefined index: Array[0][2] in /users/student/gsmit466/public_html/arraytest.php on line 85

    Line 85: ".$_SESSION["$tarray[$rowNum][0][2]"]."


    THANKS
     
  2. ez4me2c3d

    ez4me2c3d Cold Member

    Joined:
    Sep 19, 2003
    Messages:
    1,836
    Likes Received:
    0
    Location:
    Minneapolis, MN
    I don't see anything there that could lead me to help you. post more of the code.
     
  3. ez4me2c3d

    ez4me2c3d Cold Member

    Joined:
    Sep 19, 2003
    Messages:
    1,836
    Likes Received:
    0
    Location:
    Minneapolis, MN
    first of all session variables are set like this
    Code:
    $_SESSION['username'] = 'Anthony';
    Not like how you're doing it
    Code:
    $_SESSION['anthony']
     
  4. ge0

    ge0 New Member

    Joined:
    Oct 31, 2005
    Messages:
    8,398
    Likes Received:
    0
    Location:
    JERSEY
    I am trying to get that rowNum from the form below that using javascript and transporting that value to where you see rowNum in the session statement.

    http://pastebin.com/m7684749

    I pasted it there to be formatted better.
     
  5. whup

    whup I wish you had children and.. so that I could step

    Joined:
    Feb 12, 2007
    Messages:
    1,603
    Likes Received:
    0
    It looks like the error is in $tarray, not the $_SESSION.

    $tarray[$rowNum] seems to evaluate to an Array correctly.

    You're then trying to get a value from that supposedly multi-dimensional array, but it's not working because as the notice suggests, those entries don't exist.

    Break it up a bit more and you'll be able to figure it out.

    $theArray = $tarray[$rowNum];
    $nextArray = $theArray[0];
    $value = $nextArray[2];

    Then $value will contain the index into $_SESSION you want:

    $_SESSION["$value"]

    So break it up and see where it falls over, as there's too much happening in that one statement. If you need to, check what everything's value is:

    $theArray = $tarray[$rowNum];
    print_r($theArray);
    $nextArray = $theArray[0];
    print_r($nextArray);
    $value = $nextArray[2];
    print_r($value);
     

Share This Page