Hi,
I am having a problem with a session array in a shopping cart.....
I have a session array for each attribute of the product eg
sofa_name, sofa_id, sofa_type etc
The first product entered into the cart is fine, but when I add a second and subsequent product two of the session arrays do not write properly, they add to the existing value and do not create another element in that array...what is strange only 2 behave like this....
Here is the code that I use to add to the arrays:
$SESSION['sofa_id'][$newnum]=$new_sofa_id;
$SESSION['sofa_type'][$newnum]=$new_sofa_type;
$SESSION['sofa_series_name'][$newnum]=$new_sofa_series_name;
$SESSION['sofa_series_price'][$newnum]=$new_sofa_series_price;
$SESSION['sofa_width'][$newnum]=$new_sofa_width;
$SESSION['sofa_depth'][$newnum]=$new_sofa_depth;
$SESSION['sofa_height'][$newnum]=$new_sofa_height;
$SESSION['sofa_name'][$newnum]=$new_sofa_name;
$SESSION['sofa_type_name'][$newnum]=$new_sofa_type_name;
$SESSION['sofa_supplement_name'][$newnum]=$new_sofa_supplement_name;
$SESSION['sofa_supplement_price'][$newnum]=$new_sofa_supplement_selling_price;
$SESSION['sofa_material'][$newnum]="";
and here is the session variable
sofa_id|s:2:"11";
sofa_type|a:2:{i:0;s:1:"1";i:1;s: 1:"2";}
sofa_series_name|a:2:{i:0;s:1:"A";i:1;s:1:" A";}
sofa_series_price|a:2:{i:0;s:6:"997.50";i:1;s:6:"5 33.75";}
sofa_width|a:2:{i:0;s:3:"165";i:1;s:3:"187";}
sofa_ depth|a:2:{i:0;s:2:"87";i:1;s:2:"87";}
sofa_height|a:2:{i:0;s:2:"65";i:1;s:2:"56";}
sofa_name|s:5:"DDtti";
sofa_type_name|a:2:{i:0;s:7:"Set 3+2";i:1;s:10:"Sofa 3 Plz";}sofa_supplement_name|a:2:{i:0;N;i:1;N;}
sofa_supplement_price|a:2:{i:0;N;i:1;N;}
sofa_material|a:2:{i:0;s:0:"";i:1;s:0:"";}
note that it is the sofa_id array and sofa_name array that are behaving strangely, there is only 1 element in them and there should be 2...ie sofa_id|a:2:{i:0;s:1:"1";i:1;s:1:"1";} and sofa_name|a:2:{i:0;s:5:"Dutti";i:2;s:5:"Dutti";} when the first lot of data goes into the session variable it does treat it as an array, but then when the 2nd and subsequent lots are added they go back to a variable? This is really puzzling as it should not happen!
php seems to be appending them when it should be creating a new element in the array...does anyone know what is happenning?
Thanks,
Glen