CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    Feb 2011
    Posts
    0

    Angry Shopping cart problem (it is not working on few computers)

    Hi all,

    We are having problems in the shopping cart created. It says "Shopping cart" is empty some pc's but on some pc's it is functioning properly. The shopping cart is working from my side but from client side (on client's pc's) it is some pc's working and some pc's not.

    Here under I am giving the complete code that is functioning when clicking on the add to cart button. Can someone assist me better and tel me what actually is the problem inside the code.

    I thanks to all of you.

    Regds,
    Yogendra

    PHP Code:
    <?php include("admin/includes/session.php"); ?>
    <?php 
    include("checkextension.php"); ?>
    <?php 
    include("checkhttp.php"); ?>
    <?php 
    include("admin/includes/connection.php"); ?>
    <?php
    /*
     $invoiceQuery="select max(invoice_no) as invoice_no from cart";
         $invoiceQueryresult=mysql_query($invoiceQuery); 
         $row=mysql_fetch_array($invoiceQueryresult);
         $invoice_no=$row['invoice_no']+1;
         $updtQuery="update cart set invoice_no='".$invoice_no."' where rand_value='".$randnum."'";

    */
    $session_id=session_id();
    $today=date("Y-n-j H:i:s");
    $ip_address=$_SERVER['REMOTE_ADDR'];
    $rand_number=rand()."".rand()."".rand(51000);
    //echo $rand_number;
    //know invoice number
    $invoiceQuery="select *  from cart";
         
    $invoiceQueryresult=mysql_query($invoiceQuery); 
         
    $num=mysql_num_rows($invoiceQueryresult);
         if(
    $num ==0)    
         {
    $invoice_no="1000";}
         else
         {
         
    $invoice_no="0";
         }
    ////////////////////
    $product_id=@array_values($_POST['product_id']);
    if ((
    count($product_id)>0))
    {
    $product_id=@implode(',',@array_values($_POST['product_id']));
    }
    $recommended_quantity=@array_values($_POST['recommended_quantity']);
    if ((
    count($recommended_quantity)>0))
    {
    $recommended_quantity=@implode(',',@array_values($_POST['recommended_quantity']));
    }
    //echo "<br><br><br>Product IDs: ".$product_id."<br><br>";
    //echo "Product Qtys: ".$recommended_quantity."<br><br>";
    ///// fetching the user email /////
          
    $result_user mysql_query("select * from customers where email = '".$_SESSION['myusername']."'");
          while(
    $row_user mysql_fetch_array($result_user))
              {
              
    $user_id=$row_user['id'];
              
    $user_country_id=$row_user['country'];
              }
    ///////////////
    ?>
    <?php
    /////////////// Adding main product not recommended products ////////////////////
    $pid=$_POST['pid'];
    $product_color=$_POST['product_color'];
    $measurement_size=$_POST['measurement_size'];
    $quantity=$_POST['quantity'];
    $result mysql_query("SELECT * FROM product where id = ".$pid."");
    while(
    $row mysql_fetch_array($result))
      {
      
    $unit_price=$row['unit_price'];
      
    $special_price=$row['special_price'];
      
    $discount_price=$row['discount_price'];    
                        if(
    $special_price!=0.00)
                        {
                        
    $product_price=$special_price;
                        }
                        elseif(
    $discount_price!=0.00)
                        {
                        
    $product_price=$discount_price;
                        }
                        else
                        {
                        
    $product_price=$unit_price;
                        }  
       
    $weight=$row['product_weight1'];    
       
    $total_weight=$weight*$quantity;
       
    $total_price=$product_price*$quantity;
      }  
    $sql="insert into cart(user_id, product_id, unit_price, qty, weight, totalweight, product_color, measurement_size, subtotal, sess_id, ip_address, payment_status, rand_value, login_chk, invoice_no, is_wishlist, modified, created)VALUES('".$user_id."', '".$pid."', '".$product_price."', '".$quantity."', '".$weight."', '".$total_weight."', '".$product_color."', '".$measurement_size."', '".$total_price."', '".$session_id."', '".$ip_address."', '0', '".$rand_number."', '', '".$invoice_no."', 'No', '".$today."', '".$today."')";
    $result=mysql_query($sql);
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    $productArray explode(","$product_id);
    $qtyArray explode(","$recommended_quantity);
    $i 0;
    foreach(
    $productArray as $productid)
    {
    $result mysql_query("SELECT * FROM product where id = ".$productid."");

    while(
    $row mysql_fetch_array($result))
      {
      
    $unit_price=$row['unit_price'];
      
    $special_price=$row['special_price'];
      
    $discount_price=$row['discount_price'];    
                        if(
    $special_price!=0.00)
                        {
                        
    $product_price=$special_price;
                        }
                        elseif(
    $discount_price!=0.00)
                        {
                        
    $product_price=$discount_price;
                        }
                        else
                        {
                        
    $product_price=$unit_price;
                        }
      
       
    $weight=$row['product_weight1'];    
       
    $total_weight=$weight*$qtyArray[$i];
       
    $total_price=$product_price*$qtyArray[$i];
      }

    if(
    $qtyArray[$i] != 0)
    {
    $sql="insert into cart(user_id, product_id, unit_price, qty, weight, totalweight, subtotal, sess_id, ip_address, payment_status, rand_value, login_chk, invoice_no, is_wishlist, modified, created)VALUES('".$user_id."', '".$productid."', '".$product_price."', '".$qtyArray[$i]."', '".$weight."', '".$total_weight."', '".$total_price."', '".$session_id."', '".$ip_address."', '0', '".$rand_number."', '', '".$invoice_no."', 'No', '".$today."', '".$today."')";
    $result=mysql_query($sql);
    //echo "Name " . $nameArray[$i] . " shoud correspond with Email " . $email . "<br>";
    }
    else
    {
    echo 
    "";
    }

    $i++;
    }  
    header("location:shopping-cart");
    ?>
    Last edited by PeejAvery; February 22nd, 2011 at 07:16 AM. Reason: Added PHP tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured