wds Posted July 22, 2007 Share Posted July 22, 2007 For some reason the data is not being logged by the session. I believe it is because I am not declaring my $cart array correctly. Is $_SESSION[$cart] the incorrect way to go about this? It keeps finding $four == null meaning the data was not saved. This can be observed by the fact that it prints "asdf" instead of "fdsa". Ideas? session_start(); $_SESSION[$cart]; $image = $_GET['image']; if($cart[$image][0][0] == null){ $four = $_GET['four']; print("asdf"); }else{ $four = $four + $_GET['four']; print("fdsa"); } if($cart[$image][1][0] == null){ $five = $_GET['five']; }else{ $five = $five + $_GET['five']; } if($cart[$image][2][0] == null){ $eight = $_GET['eight']; }else{ $eight = $eight + $_GET['eight']; } $cart = array( $image => array( "four" => array( $four ), "five" => array( $five ), "eight" => array( $eight ) ) ); print("<html><body>"); print("<img src=/images/" . $image . "> 4x6: " . $cart[$image]['four'][0] . " 5x8: " . $cart[$image]['five'][0] . " 8x10: " . $cart[$image]['eight'][0]); print("</body></html>"); Quote Link to comment Share on other sites More sharing options...
Barand Posted July 22, 2007 Share Posted July 22, 2007 <?php session_start(); $cart = $_SESSION['cart']; // get session data // // changes to cart data // $_SESSION['cart'] = $cart; // save updated cart in session data ?> Quote Link to comment Share on other sites More sharing options...
wds Posted July 23, 2007 Author Share Posted July 23, 2007 i used what advice you gave barand, yet still my session does not log my data. does the session restart everytime the script is run? it keeps printing "asdf" because $cart[$image][0][0] keeps producing null even though data should have been set to it. ??? Quote Link to comment Share on other sites More sharing options...
JayBachatero Posted July 23, 2007 Share Posted July 23, 2007 Try doin a print_r to see what data is in the array. print_r($cart); Quote Link to comment Share on other sites More sharing options...
wds Posted July 24, 2007 Author Share Posted July 24, 2007 Jay and Barand, i can't thank ya'll enough. I am moving along in development quite nicely now, and ya'll were very helpful. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.