Hi,
I doing a cart for a client, that just requeried, that his
cart send by e-mail all products that the users choice in the
catalog. that's works fine...
but I have a session error every new item select, and display
in the cart. any one can help me to fix this?.
I based all with this tuturial..
http://www.adobe.com/devnet/dreamweaver/articles/php_cart.html
The error is this..
Notice: A session had already been started - ignoring
session_start() in D:\www\peachpit\php_cart\db.php on line 41
Warning: Cannot modify header information - headers already
sent by (output started at D:\www\shopcorp\php_cart\db.php:41) in
D:\www\shopcorp\php_cart\db.php on line 42
thanks for any help with this?
this is the code..
<?php
// This page contains the connection routine for the
// database as well as getting the ID of the cart, etc
$dbServer = "localhost";
$dbUser = "root";
$dbPass = "";
$dbName = "cart";
function ConnectToDb($server, $user, $pass, $database)
{
// Connect to the database and return
// true/false depending on whether or
// not a connection could be made.
$s =
@MySQL_connect($server, $user, $pass);
$d =
@MySQL_select_db($database, $s);
if(!$s || !$d)
return false;
else
return true;
}
function GetCartId()
{
// This function will generate an encrypted string and
// will set it as a cookie using set_cookie. This will
// also be used as the cookieId field in the cart table
if(isset($_COOKIE["cartId"]))
{
return $_COOKIE["cartId"];
}
else
{
// There is no cookie set. We will set the cookie
// and return the value of the users session ID
session_start();
setcookie("cartId", session_id(), time() + ((3600 * 24) *
30));
return session_id();
}
}
?>