Jump to content


  • Posts

  • Joined

  • Last visited

RyanJ's Achievements


Newbie (1/14)

  • First Post
  • Conversation Starter
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges



  1. Sorry for the delay--was out of reach of the computer for the weekend. I am not using an existing package at all. The whole of the script is 41 lines long, including line breaks, so there isn't much room for anything to be going wrong. $test is not defined anywhere else in the script, nor was $cart. Given how short the script is, the most scoping that occurs is in basic if blocks, and the variable is defined outside of one, in the highest block. The only thing unique to the word "cart" is that it's also the key to the cart within $_SESSION. Perhaps there is some shortcut enabled somewhere that allows you quick access to associative arrays by just using a variable with the same name as a key? That would explain the behavior well enough (setting $cart to a blank array would be blasting the session variable right before it's assigned). I'm going to test this idea out with another session variable in the near future when I get a little extra time.
  2. With a bit more echo-work, the session variable is blasted when the variable $cart is set to an array. echo $_SESSION["cart"][0][1]; before the assignment returns the correct value. echo $_SESSION["cart"][0][1]; after the assignment returns nothing. The rest of the script is working as it should. Edit: And I've got it working. Changing the variable name from $cart to $test makes it work, defying all reason that I can see (but still making me very happy!). $cart is not used prior in the script--its whole life can be seen in the snippet above. Anyone have any clue as to why the variable name would be messing with things on the TCH servers? I'm just ignorant and curious.
  3. With more echo work, here's the scenario: 1) Item is added to cart. All is well. 2) Another item is requested to be added to the cart. Immediately before the snippet above, the session variable is correct. Immediately after the snippet, the first item has been lost. The count of the array is only 1. 3) Repeat 2. Perhaps the session array can only accept simple scalar values? That doesn't seem correct since the site works on my machine. There was another difference between my machine and TCH that might be enlightening. Prior to uploading, the site worked fine. On uploading, I received errors because I was starting a session after generating output. This was corrected easily enough with some reorganization, but perhaps it highlights some difference that might lead to a solution.
  4. Hey guys, I seem to be having some problems getting PHP sessions to work out on my site. I'm not the best scripter, but I can usually do well enough to get by. This time, though, I don't have as much time to try to track down what's messing up, so I was hoping for some help :-). Basically, I have a site which works fine on my own server, but it is not working when moved to my TCH account. I've created a small shopping cart, but on TCH, the session only seems to remember the last item put into it. The session variable is $_SESSION["cart"], which holds an array of items, each item being an array of attributes as well. I plan on doing pulls from the database for the attributes in the future, but for now I'm just trying to get what I have now working. The only place in the code that's being touched where the $_SESSION variable is being updated: $cart = array(); if(isset($_SESSION["cart"])) $cart = $_SESSION["cart"]; array_push($cart, $item); $_SESSION["cart"] = $cart; The site can currently be found at www.irish.josbweb.com. Anyway, thanks for any help you can give. And if I've read other posts well enough over the years, I give a hardy "good to be here" in response to the incoming deluge of "welcome"s!
  • Create New...