PDA

View Full Version : Shopping Cart wid Sessions-pls help


nisrin
02-21-2006, 01:39 PM
hi

Im using session arrays for a shopping cart and Im getting a few error, please read my code:

<?php
session_start();
$sess_Itempointer = 0;
$sess_Itempointer = $_SESSION["sess_Itempointer"]+1;
$_SESSION["sess_Itempointer"]=$sess_Itempointer;

//shopping baskets for arrays of name, qty,
//price and cost. A variable for total cost.
$ses_basket_tcost;
$ses_basket_name[10];
$ses_basket_quantity[10];
$ses_basket_price[10];
$ses_basket_cost[10];

//getting the items from the web page.
$ses_basket_name[$sess_Itempointer]=$_POST["id"];
$ses_basket_quantity[$sess_Itempointer]=$_POST["quantity"];
$ses_basket_price[$sess_Itempointer]=$_POST["price"];
$ses_basket_cost[$sess_Itempointer]= $_POST["quantity"] * $_POST["price"];
$ses_basket_tcost+= $ses_basket_cost[$sess_Itempointer];

// register the new basket in the session
session_register("ses_basket_name");
session_register("ses_basket_quantity");
session_register("ses_basket_price");
session_register("ses_basket_cost");
session_register("ses_basket_tcost");

?>
<html>
<head>
<title>Order Page</title>
<link rel="stylesheet" type="text/css" href="../../../mystyle.css"/>
</head>
<body>
<h1>Order Page</h1>
<p>
<div align="center">
<table bordercolor="#C0C0C0" style="border-collapse: collapse; color:#CCCCFF ;font-

family:'Palatino Linotype'" cellpadding="8" cellspacing="1" border="5" width="0" >
<tr>
<th>
&nbsp; Product Name
</th>
<th>
&nbsp; Quantity Ordered
</th>
<th>
&nbsp; Product Price
</th>
<th>
&nbsp; Total Cost
</th>
</tr>
<?php
for($i=1; $i<=$sess_Itempointer; $i++)
{
echo"<tr>
<td>
$ses_basket_name[$i]
</td>
<td>
$ses_basket_quantity[$i]
</td>
<td>
$ses_basket_price[$i]
</td>
<td>
$ses_basket_cost[$i]
</td>
</tr>";
}
?>
<tr>
<th colspan = 3>
&nbsp; Total Cost in Shopping Cart &nbsp;
</th>
<td>
<?php echo $ses_basket_tcost; ?>
</td>
</tr>
</table>
</div>
</p>
</body>
</html>


The error I get is:
Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

Besides this the previous session arrays dont get printed......

Thank you so much Once Again....