Jump to content

zeekonia2002

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

zeekonia2002's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Wow, that's insane! The production server I'm using is on a shared Network Solutions hosting package and by default it was on! You would think a company as big and successful as them would know to turn it off.
  2. YYYYEEEESSSS!!!!! IT WORKSSSS!!!!!! WOOOOOHHHOOOOOOO!!!!!! I did a comparison between the php.ini files on my machine and the production server. I turned off 'Register Globals' in the php.ini file on the production server and now the cart is working perfectly! Sorry, I'm not a formally trained programmer. When would I ever need register globals to be on?
  3. Hi Everyone, I'm building a custom shopping cart. I'm having trouble getting my code to work on a production server that is running PHP version 5.2.17. My test machine is running version 5.3.0 and the code works just fine. I do not have the ability to upgrade the version of PHP on the production machine. Here is part of my code. If we can fix this, I can fix the other switch cases: //this code adds the item to the cart and creates an array and session variable for the cart. The array is multidimensional (item id1 => quantity, item id2 => quantity, item id3 => quantity and so on...). if (isset($_GET["action"])) { $action = $_GET["action"]; $id = $_GET["id"] ; $q = $_GET["quantity"]; $cart = array(); switch ($action) { case "add": if ($_SESSION["cart"]) { $cart = $_SESSION["cart"]; if (array_key_exists($id,$cart)) { $cart[$id] = $cart[$id] + $q; } else { $cart[$id] = $q; } } else { $cart[$id] = $q; } $_SESSION["cart"] = $cart; break; } } //this code displays the cart array if ($_SESSION["cart"]) { $cart = $_SESSION["cart"]; foreach($cart as $key => $value) { $runQ1 = mysql_query("SELECT * FROM products WHERE id='$key'") or die(mysql_error()); $results = mysql_fetch_array($runQ1); print "<table><tr><td>$results[1]</td><td>$results[2]</td><td>$results[3]</td><td>$results[4]</td></tr></table>"; } } else { print "<table><tr><td>There are no items in your shopping cart.</td></tr></table>"; } The cart session variable is being set but it is only holding one item at a time. If I add a second item to the cart, the 1st item disappears and only the second one is present in the session variable and the table. I'm not sure if it is a session problem or an array problem. Please help before I lose all of my hair! I don't understand why this code works on 5.3.0 and not 5.2.17... Thanks in advance! -Isaac
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.