MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 2nd, 2006, 03:10 PM
ColdStonE ColdStonE is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 2 ColdStonE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old June 5th, 2006, 01:26 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
The warning you see is caused when you try and send characters before yo usend the header().

Make sure any header() or session_start() functions are the first thing in your PHP script, and make sure there are no spaces before the opening PHP tag <?
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Shopping cart


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway