co.ador Posted September 5, 2009 Share Posted September 5, 2009 function AddItem($itemId, $qty) $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 function UpdateItem($itemId, $qty); mysql_query("UPDATE cart SET qty = $qty WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId"); } function RemoveItem($itemId) { mysql_query("DELETE FROM cart WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId"); } Link to comment https://forums.phpfreaks.com/topic/173178-please-some-help-with-this-functions-set-up-i-think-i-am-missing-some-brackets/ Share on other sites More sharing options...
kratsg Posted September 5, 2009 Share Posted September 5, 2009 function AddItem($itemId, $qty) $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 function UpdateItem($itemId, $qty); mysql_query("UPDATE cart SET qty = $qty WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId"); } function RemoveItem($itemId) { mysql_query("DELETE FROM cart WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId"); } You are missing brackets: function AddItem($itemId, $qty){ $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); mysql_query("UPDATE cart SET qty = $qty WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId"); } function RemoveItem($itemId) { mysql_query("DELETE FROM cart WHERE cookieId = '" . GetCartId() . "' AND itemId = $itemId"); } Also, to call a function, you don't state "function UpdateItem();" but rather "UpdateItem();" Link to comment https://forums.phpfreaks.com/topic/173178-please-some-help-with-this-functions-set-up-i-think-i-am-missing-some-brackets/#findComment-912869 Share on other sites More sharing options...
co.ador Posted September 5, 2009 Author Share Posted September 5, 2009 Can you please sing where am I missing brackets please? Link to comment https://forums.phpfreaks.com/topic/173178-please-some-help-with-this-functions-set-up-i-think-i-am-missing-some-brackets/#findComment-912925 Share on other sites More sharing options...
Batosi Posted September 5, 2009 Share Posted September 5, 2009 Err when he posted your code a second time he fixed it up. Link to comment https://forums.phpfreaks.com/topic/173178-please-some-help-with-this-functions-set-up-i-think-i-am-missing-some-brackets/#findComment-912940 Share on other sites More sharing options...
co.ador Posted September 5, 2009 Author Share Posted September 5, 2009 ok I saw the opening bracket was not present thank you... Link to comment https://forums.phpfreaks.com/topic/173178-please-some-help-with-this-functions-set-up-i-think-i-am-missing-some-brackets/#findComment-913128 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.