Jump to content

Thingee

Members
  • Posts

    4
  • Joined

  • Last visited

    Never

About Thingee

  • Birthday 10/06/1987

Contact Methods

  • AIM
    killedfreak
  • Website URL
    http://www.geekroots.com

Profile Information

  • Gender
    Not Telling
  • Location
    California

Thingee's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Alright I got it figured out. I don't know why but when I first wrote the code I used the following... [code] if(!isset($_SESSION["cart"])){ $_SESSION["CART"] = NULL; } [/code] I just changed null to array(); and that fixed the problem :). Thanks for everyone's help!
  2. The code works on localserver. Items get added correctly without any errors. I do have all the error reports turned on too on my localserver. Now the other server is on a certain hosting company so I can't make changes to their php.ini file =/. Sorry about the little info I gave. The file that adds items to the cart and uses the function above is manage.php. So the url looks like this... manage.php?act=add&pid=X. Manage.php looks like this... [code] <?php if (isset($_GET["act"])) {     if ($_GET["act"] == "add") // add item     {         //unserialize($_SESSION["cart"]);         if (!isset($_SESSION["cart"]))         {             // add first item             $cart->add_item_to_cart($_GET["pid"],1);         }         else if (array_key_exists($_GET["pid"], $_SESSION["cart"]))         {             // add 1 to quantity if item in cart already             $cart->add_item_to_cart($_GET["pid"],++$_SESSION["cart"][$_GET["pid"]][1]);         }         else         {             // add any other items after first item             $cart->add_item_to_cart($_GET["pid"],1);         }     }     elseif ($_GET["act"] == "del") // delete item     {         $cart->del_item($_GET["pid"]);         } } ?> [/code] Here is the full function for adding an item to the cart... [code] <?php function add_item_to_cart($id, $quantity)     {         // set cookie and store value in session         $this->setstp();             db_connect();         $sel_products = mysql_query("SELECT special_pick, special, price, artist, album FROM products WHERE id=".$id."");         $item = mysql_fetch_array($sel_products);         // returns the number of rows in a result, if 1 item exists if 0 item doesn't exists.         $num_rows = mysql_num_rows($sel_products);         // if item exists then add item to cart         if ($num_rows >= 1)         {             session_regenerate_id(TRUE);                  $_SESSION["cart"][$id][0] = $id;             $_SESSION["cart"][$id][1] = $quantity;                          $_SESSION["cart"][$id][2] = $item['$special_pick] != 0 ? 'y' : 'n';             $_SESSION["cart"][$id][3] = $item['special_pick'];             $_SESSION["cart"][$id][4] = $item['special'] == '0.00' ? '0.00' : $item['special'];             $_SESSION["cart"][$id][5] = $item['price'];             $_SESSION["cart"][$id][6] = $item['artist'];             $_SESSION["cart"][$id][7] = $item['album'];         header ("location:".$_SERVER['HTTP_REFERER']);                      }     } ?> [/code] Thanks for helping me :).
  3. [!--quoteo(post=360666:date=Apr 1 2006, 10:53 AM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Apr 1 2006, 10:53 AM) [snapback]360666[/snapback][/div][div class=\'quotemain\'][!--quotec--] not 100% sure on the reasons behind your error without checking, but the reason why you get it on one server and not the other is normally down to how strict the error_reporting is in your php.ini file. [/quote] True. The server not having problems is a slackware box that I'm running at my house. The one having trouble is an actual hosted server with some company. Is there any information you would need to know in order to really know why I'm having this error?
  4. I'm writing a simple cart script right now and for some reason when I moved it to another server I got these errors when I try to add an item to the cart... [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: Cannot use a scalar value as an array in /home/joeystec/public_html/test/php/lib/cart.inc.php on line 42 Warning: Cannot use a scalar value as an array in /home/joeystec/public_html/test/php/lib/cart.inc.php on line 43 Warning: Cannot use a scalar value as an array in /home/joeystec/public_html/test/php/lib/cart.inc.php on line 51 Warning: Cannot use a scalar value as an array in /home/joeystec/public_html/test/php/lib/cart.inc.php on line 53 Warning: Cannot use a scalar value as an array in /home/joeystec/public_html/test/php/lib/cart.inc.php on line 54 Warning: Cannot use a scalar value as an array in /home/joeystec/public_html/test/php/lib/cart.inc.php on line 55 Warning: Cannot use a scalar value as an array in /home/joeystec/public_html/test/php/lib/cart.inc.php on line 56 Warning: Cannot use a scalar value as an array in /home/joeystec/public_html/test/php/lib/cart.inc.php on line 57[/quote] The code that adds the stuff onto the cart is the following... (Note: Lines 42-57 are the lines like $_SESSION["cart"][$id][X]) [code] // set cookie and store value in session $this->setstp(); db_connect();         $sel_products = mysql_query("SELECT special_pick, special, price, artist, album FROM products WHERE id=".$id."");         $item = mysql_fetch_array($sel_products);         // returns the number of rows in a result, if 1 item exists if 0 item doesn't exists.         $num_rows = mysql_num_rows($sel_products);         // if item exists then add item to cart         if ($num_rows >= 1)         {             session_regenerate_id(TRUE);                  $_SESSION["cart"][$id][0] = $id;             $_SESSION["cart"][$id][1] = $quantity;             $_SESSION["cart"][$id][2] = $item['$special_pick] != 0 ? 'y' : 'n';             $_SESSION["cart"][$id][3] = $item['special_pick'];             $_SESSION["cart"][$id][4] = $item['special'] == '0.00' ? '0.00' : $item['special'];             $_SESSION["cart"][$id][5] = $item['price'];             $_SESSION["cart"][$id][6] = $item['artist'];             $_SESSION["cart"][$id][7] = $item['album'];         header ("location:".$_SERVER['HTTP_REFERER']);                      } [/code] I don't understand how this code works on one server and not the other. So right now it currently does not add anything on the cart. Any ideas?
×
×
  • 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.