I have done a shopping cart which works except that when I click on the remove image file:
it removes the item from the database but then generates the error:
You have an error in your SQL syntax.
Check the manual that corresponds to your MySQL server version for the right syntax
to use near ' , '' ,'')' at line 1
Here is the code for the page:
Any ideas as to the error, please?
Code:
<a href = "ShoppingBag.php?removeitem=<?php echo $row["cartId"]; ?>">
<IMG src="Images/Del.jpg"></A>
it removes the item from the database but then generates the error:
You have an error in your SQL syntax.
Check the manual that corresponds to your MySQL server version for the right syntax
to use near ' , '' ,'')' at line 1
Here is the code for the page:
Code:
<?php
include("db.php");
if (!empty($_REQUEST['removeitem'])) {
RemoveItem($_REQUEST['removeitem']);
}
global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database
$cxn = mysql_connect($dbServer, $dbUser, $dbPass, $dbName) or die
(mysql_error());
$db = mysql_select_db("kraffs5_actuacoscart", $cxn) or die(mysql_error());
$sql = ("insert into cart(cookieId, ITEMID, QTY,COLOR,SIZE) values
('" . GetCartId() . "', $ITEMID, $QTY, '$COLOR' ,'$SIZE')") or die(mysql_error
());
@mysql_query("insert into cart(cookieId, ITEMID, QTY,COLOR,SIZE) values('" . GetCartId() . "', $ITEMID, $QTY, '$COLOR' ,'$SIZE')") or die (mysql_error()); ;
ShowCart();
function RemoveItem($cartId)
{
// Uses an SQL delete statement to remove an item from
// the users cart
global $dbServer, $dbUser, $dbPass, $dbName;
// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName) or die(mysql_error());
mysql_query("delete from cart where cookieId = '" . GetCartId() . "' and cartId = $cartId") or die(mysql_error());
}
Any ideas as to the error, please?