Problem defining variable

ok i fixed the size/submit problem (thanks for that, I forgot I changed it )so now this is what is happening now:

Array ( [username] => lostnvegas [size] => [cart_array] => Array ( [1] => Array ( [item_id] => 13 [quantity] => 1 [size] => ) ) )
Notice: Undefined variable: size in /home/content/36/8631036/html/cart/cart.php on line 138

Notice: Undefined variable: size in /home/content/36/8631036/html/cart/cart.php on line 149

Can you show me the code in those 2 lines I cant guess what they are.
Now that we have submit right we need to go back to the start again.

we suddenly have [size] => popping up in the array that was not there before so maybe delete the
from the form
[php] $_SESSION[‘size’] = $_POST[‘size’];[/php]

lol sorry bout that…ya know; this would almost be funny if it wasn’t happening to me…

these are the errors again:
size is not set
Notice: Undefined variable: pid in /home/content/36/8631036/html/cart/cart.php on line 31

Notice: Undefined variable: pid in /home/content/36/8631036/html/cart/cart.php on line 31

Notice: Undefined variable: pid in /home/content/36/8631036/html/cart/cart.php on line 33

Notice: Undefined variable: size in /home/content/36/8631036/html/cart/cart.php on line 33

Warning: Cannot modify header information - headers already sent by (output started at /home/content/36/8631036/html/cart/cart.php:18) in /home/content/36/8631036/html/cart/cart.php on line 43

[php]
31 if ($key == “item_id” && $value == $pid) {

33 array_splice($_SESSION[“cart_array”], $i-1, 1, array(array(“item_id” => $pid, “quantity” => $each_item[‘quantity’] + 1, “size” => $size)));

43 header(“location: cart.php”);

[/php]

Back to this again fingers crossed we get the right this this time

put at the top after session start

[php]if (isset($_POST[‘pid’])&&(isset($_POST[‘size’]))){
$pid = $_POST[‘pid’];
$size = $_POST[‘size’];
echo ‘size = ‘.$size.’
’;
}else{
echo 'size is not set
';
}[/php]

ok, got this:

size is not set
size is not set
Warning: Cannot modify header information - headers already sent by (output started at /home/content/36/8631036/html/cart/cart.php:8) in /home/content/36/8631036/html/cart/cart.php on line 50

lines 8 and 50:

[php]
8 echo 'size is not set
';

50 header(“location: cart.php”);
[/php]

Can you show me the code for both pages that you have as I have it working on my machine.

So I want to see what you have that might need changing.
I commented out these 2 lines and the variable is assigned

[php]

header(“location: cart.php”);

exit();

[/php]

Sure thing, there are three pages involved including the index.php so I’ll post all three in order so if you don’t need the index.php just ignore it:

[php]

<?php **//index.php//** session_start(); $_SESSION['username']==$dbusername; $_SESSION['size'] = $_POST['size']; echo "

Welcome ".$_SESSION['username']."!"; ?> <?php //featured items include "storescripts/connect_to_mysql.php"; $featured_list=""; $sql=mysql_query("SELECT * FROM products ORDER BY product_name ASC LIMIT 1"); //this number changes the number of featured items shown on the blackmarket page $productCount=mysql_num_rows($sql); if($productCount > 0) { while($row=mysql_fetch_array($sql)){ $id=$row["id"]; $product_name=$row["product_name"]; $product_number=$row["product_number"]; $price=$row["price"]; $category=$row["category"]; $subcategory=$row["subcategory"]; $date_added = strftime("%b %d, %Y",strtotime($row["date_added"])); $featured_list.='

' . $product_name . ' Item Number: ' . $product_number . '
' . $product_name . '
$' . $price . '
View Product Details
'; } }else{ $featured_list="There are no featured prodcts this week. Please check back next week for some ass-kicking deals!"; } mysql_close(); ?> <?php //tees include "storescripts/connect_to_mysql.php"; //run a query to get my latest six products $tees_list=""; $sql=mysql_query("SELECT * FROM products WHERE subcategory='tees' "); //this number changes the number of featured items shown on the blackmarket page $productCount=mysql_num_rows($sql); if($productCount > 0) { while($row=mysql_fetch_array($sql)){ $id=$row["id"]; $product_name=$row["product_name"]; $product_number=$row["product_number"]; $price=$row["price"]; $category=$row["category"]; $subcategory=$row["subcategory"]; $date_added = strftime("%b %d, %Y",strtotime($row["date_added"])); $tees_list.='
' . $product_name . ' Item Number: ' . $product_number . '
' . $product_name . '
$' . $price . '
View Product Details
'; } }else{ //$featured_list="There are no featured prodcts this week. Please check back next week for some ass-kicking deals!"; } mysql_close(); ?> <?php //wristbands include "storescripts/connect_to_mysql.php"; //run a query to get my latest six products $wristbands_list=""; $sql=mysql_query("SELECT * FROM products WHERE subcategory='wristbands' "); $productCount=mysql_num_rows($sql); if($productCount > 0) { while($row=mysql_fetch_array($sql)){ $id=$row["id"]; $product_name=$row["product_name"]; $product_number=$row["product_number"]; $price=$row["price"]; $category=$row["category"]; $subcategory=$row["subcategory"]; $date_added = strftime("%b %d, %Y",strtotime($row["date_added"])); $wristbands_list.='
' . $product_name . ' Item Number: ' . $product_number . '
' . $product_name . '
$' . $price . '
View Product Details
'; } }else{ //$featured_list="There are no featured prodcts this week. Please check back next week for some ass-kicking deals!"; } mysql_close(); ?> <?php //boxers include "storescripts/connect_to_mysql.php"; //run a query to get my latest six products $boxers_list=""; $sql=mysql_query("SELECT * FROM products WHERE subcategory='boxers' "); $productCount=mysql_num_rows($sql); if($productCount > 0) { while($row=mysql_fetch_array($sql)){ $id=$row["id"]; $product_name=$row["product_name"]; $product_number=$row["product_number"]; $price=$row["price"]; $category=$row["category"]; $subcategory=$row["subcategory"]; $date_added = strftime("%b %d, %Y",strtotime($row["date_added"])); $boxers_list.='
' . $product_name . ' Item Number: ' . $product_number . '
' . $product_name . '
$' . $price . '
View Product Details
'; } }else{ //$featured_list="There are no featured prodcts this week. Please check back next week for some ass-kicking deals!"; } mysql_close(); ?> <?php //hoodies include "storescripts/connect_to_mysql.php"; //run a query to get my latest six products $hoodies_list=""; $sql=mysql_query("SELECT * FROM products WHERE subcategory='hoodies' "); $productCount=mysql_num_rows($sql); if($productCount > 0) { while($row=mysql_fetch_array($sql)){ $id=$row["id"]; $product_name=$row["product_name"]; $product_number=$row["product_number"]; $price=$row["price"]; $category=$row["category"]; $subcategory=$row["subcategory"]; $date_added = strftime("%b %d, %Y",strtotime($row["date_added"])); $hoodies_list.='
' . $product_name . ' Item Number: ' . $product_number . '
' . $product_name . '
$' . $price . '
View Product Details
'; } }else{ //$featured_list="There are no featured prodcts this week. Please check back next week for some ass-kicking deals!"; } mysql_close(); ?> <?php //beanies include "storescripts/connect_to_mysql.php"; //run a query to get my latest six products $beanies_list=""; $sql=mysql_query("SELECT * FROM products WHERE subcategory='beanies' "); $productCount=mysql_num_rows($sql); if($productCount > 0) { while($row=mysql_fetch_array($sql)){ $id=$row["id"]; $product_name=$row["product_name"]; $product_number=$row["product_number"]; $price=$row["price"]; $category=$row["category"]; $subcategory=$row["subcategory"]; $date_added = strftime("%b %d, %Y",strtotime($row["date_added"])); $beanies_list.='
' . $product_name . ' Item Number: ' . $product_number . '
' . $product_name . '
$' . $price . '
View Product Details
'; } }else{ //$featured_list="There are no featured prodcts this week. Please check back next week for some ass-kicking deals!"; } mysql_close(); ?> <?php //bumper stickers include "storescripts/connect_to_mysql.php"; //run a query to get my latest six products $bumper_stickers_list=""; $sql=mysql_query("SELECT * FROM products WHERE subcategory='Bumper Stickers' "); $productCount=mysql_num_rows($sql); if($productCount > 0) { while($row=mysql_fetch_array($sql)){ $id=$row["id"]; $product_name=$row["product_name"]; $product_number=$row["product_number"]; $price=$row["price"]; $category=$row["category"]; $subcategory=$row["subcategory"]; $date_added = strftime("%b %d, %Y",strtotime($row["date_added"])); $bumper_stickers_list.='
' . $product_name . ' Item Number: ' . $product_number . '
' . $product_name . '
$' . $price . '
View Product Details
'; } }else{ //$featured_list="There are no featured prodcts this week. Please check back next week for some ass-kicking deals!"; } mysql_close(); ?> <?php //picks include "storescripts/connect_to_mysql.php"; //run a query to get my latest six products $picks_list=""; $sql=mysql_query("SELECT * FROM products WHERE subcategory='picks' "); $productCount=mysql_num_rows($sql); if($productCount > 0) { while($row=mysql_fetch_array($sql)){ $id=$row["id"]; $product_name=$row["product_name"]; $product_number=$row["product_number"]; $price=$row["price"]; $category=$row["category"]; $subcategory=$row["subcategory"]; $date_added = strftime("%b %d, %Y",strtotime($row["date_added"])); $picks_list.='
' . $product_name . ' Item Number: ' . $product_number . '
' . $product_name . '
$' . $price . '
View Product Details
'; } }else{ //$featured_list="There are no featured prodcts this week. Please check back next week for some ass-kicking deals!"; } mysql_close(); ?> <?php //buttons include "storescripts/connect_to_mysql.php"; //run a query to get my latest six products $buttons_list=""; $sql=mysql_query("SELECT * FROM products WHERE subcategory='buttons' "); $productCount=mysql_num_rows($sql); if($productCount > 0) { while($row=mysql_fetch_array($sql)){ $id=$row["id"]; $product_name=$row["product_name"]; $product_number=$row["product_number"]; $price=$row["price"]; $category=$row["category"]; $subcategory=$row["subcategory"]; $date_added = strftime("%b %d, %Y",strtotime($row["date_added"])); $buttons_list.='
' . $product_name . ' Item Number: ' . $product_number . '
' . $product_name . '
$' . $price . '
View Product Details
'; } }else{ //$featured_list="There are no featured prodcts this week. Please check back next week for some ass-kicking deals!"; } mysql_close(); ?> The Black Market
<?php include_once("styles/template_header.php"); ?>
  <tr>
  <td height="80" align="left" valign="top">
    <class="style1">
    <div align="center"><b>Tees</b><br />
      <br />
      <?php echo $tees_list; ?><br />
      <br />
      
      <class="style1"><b>Wristbands</b><br />
      <br />
      <?php echo $wristbands_list; ?><br />
      <br />
      
      <class="style1"><b>Boxers</b><br />
      <br />
      <?php echo $boxers_list; ?><br />
      <br />
      
      <class="style1"><b>Hoodies</b><br />
      <br />
      <?php echo $hoodies_list; ?><br />
      <br />
      
      <class="style1"><b>Beanies</b><br />
      <br />
    <?php echo $beanies_list; ?></div></td> 
  
  	<td height="80" align="center" valign="top"><p class="style2"><span class="style2"><?php echo $featured_list; ?></span></p>
  <div align="center">
    <div align="center"></div>
    </div></td>
  
	<td height="80" align="center" valign="top"><div align="center">
  <class="style1"><b>Bumper Stickers</b><br />
  <br />
    <?php echo $bumper_stickers_list; ?><br /><br />
	
	<class="style1"><div align="center"><b>Picks</b><br /><br />
  <?php echo $picks_list; ?></div><br /><br />
  
  <class="style1"><div align="center"><b>Buttons</b><br /><br />
  <?php echo $buttons_list; ?></div><br /><br />
  
  <div align="center">
    <div align="center"></div>
    </div></td>

Apparel

<?php echo $apparel_list; ?>

Weekly featured product:

    </span>
    <!--<table width="356" border="0">
    <tr>
      <th width="166" scope="row"><a href="product.php?"><img src="/cart/inventory_images/b4311.gif" width="158" height="149" border="1" /></a></th>
      <td width="180" valign="top"><p>Product Title</p>
        <p>Product Price</p>
        <p><a href="product.php?">View Product   </a></p></td>
    </tr>
  </table> -->
    </div></td>
<td width="275" align="left" valign="top"><div align="center">

General Merchandise


<?php include_once("styles/template_footer.php"); ?>

 

 

[/php]

[hr]

[php]

<?php // Script Error Reporting //error_reporting(E_ALL); ini_set('display_errors', '1'); error_reporting(E_ALL ^ E_NOTICE); ?> <?php $submit=$_POST['submit']; $_SESSION['size'] = $_POST['size']; // Check to see the URL variable is set and that it exists in the database if (isset($_GET['id'])) { // Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $id = preg_replace('#[^0-9]#i', '', $_GET['id']); // Use this var to check to see if this ID exists, if yes then get the product // details, if no then exit this script and give message why $sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { // get all the product details while($row = mysql_fetch_array($sql)){ $product_name = $row["product_name"]; $product_number = $row["product_number"]; $price = $row["price"]; $details = $row["details"]; $category = $row["category"]; //$size = $row["need_size"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $shipping = $row["shipping"]; } } else { echo "That item does not exist."; exit(); } } else { echo "Data to render this page is missing."; exit(); } mysql_close(); ?> <?php echo $product_name; ?>
<?php include_once("styles/template_header.php");?>
<?php echo $product_name; ?>
             View Full Size Image

<?php echo $category; ?>

<?php echo "$".$price; ?>
<?php echo "$product_name"; ?>
<?php echo $details; ?>

    </p>
	
<form id="form1" name="form1" method="post" action="cart.php">

	<p>          
      <input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" />
    </p>

  <label>Size
  <select name="size">
    <option>Select</option>
    <option value="small">Small (petite)</option>
    <option value="medium">Medium (average)</option>
    <option value="large">Large (life size)</option>
    <option value="xl">X-Large (full figured)</option>
    <option value="xxl">XX-Large (our Hindenberg line)</option>
    <option value="xxxl">XXX-Large (DAMN!!)</option>
  </select>
  </label>
  
  
 
    
    
    <input type="submit" name="submit" id="size" value="Add to Shopping Cart" />
    <p>   
     
  </form>
  </td>
</tr>

Continue Shopping








<?php include_once("styles/template_footer.php");?>
[/php]

[hr]

and the last, cart.php

[php]
[php]

<?php session_start(); // Start session first thing in script if (isset($_POST['pid'])&&(isset($_POST['size']))){ $pid = $_POST['pid']; $size = $_POST['size']; echo 'size = '.$size.'
'; }else{ echo 'size is not set
'; } // Script Error Reporting //error_reporting(E_ALL); //ini_set('display_errors', '1'); // Connect to the MySQL database include "storescripts/connect_to_mysql.php"; ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 1 (if user attempts to add something to the cart from the product page) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['pid'])&&(isset($_POST['size']))){ $pid = $_POST['pid']; $size = $_POST['size']; echo 'size = '.$size; }else{ echo 'size is not set'; $wasFound = false; $i = 0; // If the cart session variable is not set or cart array is empty if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { // RUN IF THE CART IS EMPTY OR NOT SET $_SESSION["cart_array"] = array(1 => array("item_id" => $pid, "quantity" => 1, "size" => $size)); } else { // RUN IF THE CART HAS AT LEAST ONE ITEM IN IT foreach ($_SESSION["cart_array"] as $each_item) { $i++; while (list($key, $value) = each($each_item)) { if ($key == "item_id" && $value == $pid) { // That item is in cart already so let's adjust its quantity using array_splice() array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "quantity" => $each_item['quantity'] + 1, "size" => $size))); $wasFound = true; } // close if condition } // close while loop } // close foreach loop if ($wasFound == false) { array_push($_SESSION["cart_array"], array("item_id" => $pid, "quantity" => 1, "size" => $size)); } } header("location: cart.php"); exit(); } // echo "$key => $value
"; // var_dump($_SESSION["cart_array"] ); //error_reporting(E_ALL ^ E_NOTICE); //print_r ($_SESSION); ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 2 (if user chooses to empty their shopping cart) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_GET['cmd']) && $_GET['cmd'] == "emptycart") { unset($_SESSION["cart_array"]); } ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 3 (if user chooses to adjust item quantity) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //$size = $_POST['size']; if (isset($_POST['item_to_adjust']) && $_POST['item_to_adjust'] != "") { // execute some code $item_to_adjust = $_POST['item_to_adjust']; $quantity = $_POST['quantity']; $quantity = preg_replace('#[^0-9]#i', '', $quantity); // filter everything but numbers if ($quantity >= 100) { $quantity = 99; } if ($quantity < 1) { $quantity = 1; } if ($quantity == "") { $quantity = 1; } $i = 0; foreach ($_SESSION["cart_array"] as $each_item) { $i++; while (list($key, $value) = each($each_item)) { if ($key == "item_id" && $value == $item_to_adjust) { // That item is in cart already so let's adjust its quantity using array_splice() array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $item_to_adjust, "quantity" => $quantity))); } // close if condition } // close while loop } // close foreach loop } ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 4 (if user wants to remove an item from cart) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['index_to_remove']) && $_POST['index_to_remove'] != "") { // Access the array and run code to remove that array index $key_to_remove = $_POST['index_to_remove']; if (count($_SESSION["cart_array"]) <= 1) { unset($_SESSION["cart_array"]); } else { unset($_SESSION["cart_array"]["$key_to_remove"]); sort($_SESSION["cart_array"]); } } ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 5 (render the cart for the user to view on the page) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $cartOutput = ""; $cartTotal = ""; $pp_checkout_btn = ''; $product_id_array = ''; //$size = $_POST['size']; if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { $cartOutput = "

Your shopping cart is empty

"; } else { // Start PayPal Checkout Button $pp_checkout_btn .= ' '; // Start the For Each loop $i = 0; foreach ($_SESSION["cart_array"] as $each_item) { $item_id = $each_item['item_id']; $sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1"); while ($row = mysql_fetch_array($sql)) { $product_name = $row["product_name"]; $price = $row["price"]; $details = $row["details"]; $shipping = $row["shipping"]; $pricesub = $price + $shipping; } //$size = $_POST['size']; $pricetotal = $pricesub * $each_item['quantity']; $cartTotal = $pricetotal + $cartTotal; setlocale(LC_MONETARY, "en_US"); $pricetotal = money_format("%10.2n", $pricetotal); // Dynamic Checkout Btn Assembly $x = $i + 1; $pp_checkout_btn .= ' '; // Create the product array variable $product_id_array .= "$item_id-".$each_item['quantity'].","; // Dynamic table row assembly $cartOutput .= ""; $cartOutput .= ' ' . $product_name . '
' . $product_name. ' '; $cartOutput .= '' . $details . ''; $cartOutput .= '' . print "$size" . ''; $cartOutput .= '' . $shipping . ''; $cartOutput .= '$' . $price . ''; //$cartOutput .= '$' . $price . ''; $cartOutput .= ' '; //$cartOutput .= '' . $each_item['quantity'] . ''; $cartOutput .= '' . $pricetotal . ''; $cartOutput .= ''; $cartOutput .= ''; $i++; } setlocale(LC_MONETARY, "en_US"); $cartTotal = money_format("%10.2n", $cartTotal); $cartTotal = "
Cart Total : ".$cartTotal." USD
"; // Finish the Paypal Checkout Btn $pp_checkout_btn .= ' '; } ?> Your Cart
<?php include_once("template_header.php");?>
<br />
<table width="100%" height="60" border="1" cellpadding="6" cellspacing="0">
  <tr>
    <td width="18%" bgcolor="#C5DFFA"><strong>Product</strong></td>
    <td width="30%" bgcolor="#C5DFFA"><strong>Product Description</strong></td>
	<td width="19%" bgcolor="#C5DFFA"><strong>Size</strong></td>
	<td width="5%" bgcolor="#C5DFFA"><strong>Shipping</strong></td>
	<td width="5%" bgcolor="#C5DFFA"><strong>Unit Price</strong></td>
    <td width="9%" bgcolor="#C5DFFA"><strong>Quantity</strong></td>
    <td width="9%" bgcolor="#C5DFFA"><strong>Total</strong></td>
    <td width="5%" bgcolor="#C5DFFA"><strong>Remove</strong></td>
  </tr>

 <?php echo $cartOutput; ?>
 <!-- <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
  </tr> -->
</table>
<?php echo $cartTotal; ?>
<br />

Continue Shopping



<?php echo $pp_checkout_btn; ?>
<?php include_once("styles/template_footer.php");?>
[/php] [/php]

remove these from the top
[php]$_SESSION[‘size’] = $_POST[‘size’];[/php]

Can you comment out these 2 lines they are around line 46
It looks like it exits killing the code what are you trying to do there ?
Do you get the $size assigned now ?
[php]
#header(“location: cart.php”);
#exit();
[/php]

The cart top should look more like this you don’t need the same code twice

[php]<?php
session_start();
// Start session first thing in script

// Script Error Reporting
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
// Connect to the MySQL database
include "storescripts/connect_to_mysql.php";

/////////////////////////////////////////////////////////////////////////////
//Section 1 (if user attempts to add something to the cart from the product page)
////////////////////////////////////////////////////////////////////////////
// do we have $size and $pid
if (isset($_POST[‘pid’])&&(isset($_POST[‘size’]))){
$pid = $_POST[‘pid’];
$size = $_POST[‘size’];
// make sure we have $size by printing to screen
echo ‘size = ‘.$size.’
’;

$wasFound = false;
$i = 0;
// If the cart session variable is not set or cart array is empty
if (!isset($_SESSION[“cart_array”]) || count($_SESSION[“cart_array”]) < 1) {
// RUN IF THE CART IS EMPTY OR NOT SET
$_SESSION[“cart_array”] = array(1 => array(“item_id” => $pid, “quantity” => 1, “size” => $size));
} else {
// RUN IF THE CART HAS AT LEAST ONE ITEM IN IT
foreach ($_SESSION[“cart_array”] as $each_item) {
$i++;
while (list($key, $value) = each($each_item)) {
if ($key == “item_id” && $value == $pid) {
// That item is in cart already so let’s adjust its quantity using array_splice()
array_splice($_SESSION[“cart_array”], $i-1, 1, array(array(“item_id” => $pid, “quantity” => $each_item[‘quantity’] + 1, “size” => $size)));
$wasFound = true;
} // close if condition
} // close while loop
} // close foreach loop
if ($wasFound == false) {
array_push($_SESSION[“cart_array”], array(“item_id” => $pid, “quantity” => 1, “size” => $size));
}
}
// why do you want to exit ?
echo ‘exit’;
#header(“location: cart.php”);
#exit();
}else{
// we do not have $size or $pid
echo 'size is not set
';
}[/php]

Ha! Brilliant. Now I am getting:

“size = smallsmall”

at the top of the page without error suppression. and when I print the array I get:

[php]size = smallArray ( [size] => [cart_array] => Array ( [0] => Array ( [item_id] => 9 [quantity] => 2 [size] => small ) ) ) small [/php]

I pulled the print array, and the echo at the top and it worked perfectly! You, my sir, are most definately THE MAN!!

And, I fully understand now where I was going wrong too. Just wanted to say thank you again for your time. Now I can finally move on!

ta

Some times it takes a while to find the right thing but we got there in the end. ;D

You might want to go back over the code and remove the things we added to test the code along the way, as they will not be needed now we found the problem.

So now you know that echo, print_r and var_dump are very handy, maybe you understand how to use them better now to try and find out how to see problems that are hidden.

I pressed the solved button already.
Are you using dreamweaver to edit your php ?
Maybe time to change from DW to a real editor for php and just add the code to dreamweaver whe its working.

I use two different editors (yes, unfortunately one of them is dreamweaver). The other one is PHP Expert Editor. Would you have a suggestion of another that’s better?

Its just dreamweaver does not give you live results like a php editor does I use rapidphp but its generaly down to what you use most and like the best.

Oh very cool. At the moment I don’t have a local server, though maybe I should…, that might also help with debugging ya think? Well ya guys hooked me. I think i’ll hang out and see if I can help someone else who is just starting to learn. I totally understand the code now, i’ve already added a color option as well as size. They ask me and i’ll tell em; NOODLES IS MY PHP PIMP! lol ok maybe not but seriously thanks again my friend.

I use a development server on my pc its easy to install as it does it all for you, a little program called easyphp which is simular to wamp more people use wamp but easyphp for me is much easier to install and get going.

Oh very cool, i’ll give it a spin and let ya know how that works out. I had one final question, if ya don’t mind that is, about my php. I just noticed that I have the size and color options working but they show up on every product (and some things don’t need them). I don’t want a detailed explanation but I would like to know where I should begin isolating the apparel with the type of setup I have. I think I have a good idea but I don’t want to dive into it with out a direction and since you’ve seen it inside and out I thought I’d ask your opinion?

well if it does not need one then you could just do
if item_id = 19 show this code else show that

but you might start adding categories which you could later
if category = ‘caps’{
show form
}else{
do not show form
}

Yeah I think i’ll start doing that. I had an idea where to start but I wanted to make sure I wasn’t going about it all wrong. Very cool thanks again and see ya soon!

Sponsor our Newsletter | Privacy Policy | Terms of Service