Jump to content

please some help with this functions set up I think I am missing some brackets!


co.ador

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.