I am trying to delete a primary key item_id from items table which exists in another tables (cart and Wishlist ) as a composite Primary key with other fields.
I tried this way but it not working it's print "notDeleted" as in the condition:
if(isset($_POST["deleteItem"])){
try{
$itemID = $_POST['itemID'];
require('connection.php');
$sql=$db->exec("DELETE cart,wishlist,items FROM cart ,wishlist, items WHERE cart.iid=wishlist.iid AND wishlist.iid=items.item_id AND items.item_id='$itemID'");
if($sql==1)
{
header('location:index.php');
}
else{
echo "NotDeleted";
}
$db=null;
}
catch(PDOException $e){
die($e->getMessage());
}
}
Also this is a screenshot of the error:
Can you know how to solve the problem?