
09-07-2007
|
| Administrator
Join Date: Jun 2007
Posts: 3,729
BRL$: 30,443.10 Thanks: 0
Thanked 2 Times in 2 Posts
Rep Power: 402 | | Session Array Problem 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";} 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 To view links or images in this forum your post count must be 1 or greater. You currently have 0 posts. | |
__________________ █ High Quality To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
█ Powerful To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts.
█ To view links or images in signatures your post count must be 0 or greater. You currently have 0 posts. | | | |