
June 2nd, 2006, 03:10 PM
|
|
Registered User
|
|
Join Date: Jun 2006
Posts: 2
Time spent in forums: 53 m 54 sec
Reputation Power: 0
|
|
|
Shopping cart
Hello I have used youre tutorial on this site to build a shopping cart. But I get several php errors listed below:
Quote: | Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /usr/home/digital/public_html/J&J/cart.php:6) in /usr/home/digital/public_html/J&J/db.php on line 41 |
Down here is a part of the script where the error should be but I don't see it.
PHP Code:
switch($_GET["action"])
{
case "add_item":
{
AddItem($_GET["id"], $_GET["qty"]);
ShowCart();
break;
}
case "update_item":
{
UpdateItem($_GET["id"], $_GET["qty"]);
ShowCart();
break;
}
case "remove_item":
{
RemoveItem($_GET["id"]);
ShowCart();
break;
}
default:
{
ShowCart();
}
}
function AddItem($itemId, $qty)
{
// Will check whether or not this item
// already exists in the cart table.
// If it does, the UpdateItem function
// will be called instead
global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
// Check if this item already exists in the users cart table
$result = mysql_query("select count(*) from cart where cookieId = '" . GetCartId() . "' and itemId = $itemId");
$row = mysql_fetch_row($result);
$numRows = $row[0];
if($numRows == 0)
{
// This item doesn't exist in the users cart,
// we will add it with an insert query
@mysql_query("insert into cart(cookieId, itemId, qty) values('" . GetCartId() . "', $itemId, $qty)");
}
else
{
// This item already exists in the users cart,
// we will update it instead
UpdateItem($itemId, $qty);
}
}
sorry for the long post I hope you can help.
Thanks
sorry people after I posted this message I found the problem.
Thanks anyway
Last edited by ColdStonE : June 2nd, 2006 at 03:15 PM.
Reason: Al ready works found the problem
|