# New LoadVars(); and php shopping cart

**URL:** https://forum.kirupa.com/t/new-loadvars-and-php-shopping-cart/302519
**Category:** Uncategorized
**Created:** [January 2, 2010, 6:45am UTC](https://forum.kirupa.com/t/new-loadvars-and-php-shopping-cart/302519 "2010-01-02T06:45:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![RyanGus](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@RyanGus](https://forum.kirupa.com/u/RyanGus)
#### Post date: [January 2, 2010, 6:45am UTC](https://forum.kirupa.com/t/new-loadvars-and-php-shopping-cart/302519/1 "2010-01-02T06:45:05Z")

</div>

hello, im building a shopping cart with PHP, Flash, MySql. the problem is when i try to add items to the cart they overwrite each other.

im sending the variables via loadVars from the flash to the PHP and everything is working great till i add a new item… the new item overwrite the old one… this is my php script…

\<?php  
session\_start();

extract($\_REQUEST);

mysql\_connect(“localhost”,“root”,"\*\*\*\*\*\*\*\*\*");  
mysql\_select\_db(“menosesmas\_vinyl”);

if(!isset($cantidad)){$cantidad=1;}

$qry=mysql\_query(“select \* from vinyllaves where id=’”.$id."’");  
$row=mysql\_fetch\_array($qry);

if(isset($\_SESSION[‘carro’]))  
$carro=$\_SESSION[‘carro’];

$model = $HTTP\_POST\_VARS[‘model’];  
$precio = $HTTP\_POST\_VARS[‘precio’];  
$color = $HTTP\_POST\_VARS[‘colorname’];  
$cantidad = $HTTP\_POST\_VARS[‘cantidad’];

$carro[md5($id)]=array(‘identificador’=\>md5($id),‘cantidad’=\>$cantidad,‘model’=\>$model,‘precio’=\>$precio,‘id’=\>$id,‘colorname’=\>$color);

$\_SESSION[‘carro’]=$carro;

header(“Location:vercarrito.php?”.SID);  
?\>
