session in shopping cart page
I'm doing shopping cart with PHP at the book "Beginning PHP5,Apache and MySQL web development" .
i want to display the number of item that user bought in "cbashop.php"
So, I write the code the same as "cart.php" :
$sessid = session_id();
$query = "select * from carttemp where carttemp_sess = '$sessid'";
$results = mysql_query($query) or die(mysql_query());
$rows = mysql_num_rows($results);
But in the cbashop.php. It display th error:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\php\html\Products_Pages\products.php:5) in C:\php\html\Products_Pages\cart12.php on line 4
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\php\html\Products_Pages\products.php:5) in C:\php\html\Products_Pages\cart12.php on line 4
Can u help me to fix the problem?
By the way, Can U show me some ideas if I create username and password for customer ( create account for customer when they buy product). What I have to do?
Thank U for reading my messege.