hi, im trying to get my stock field in my database to decrease when a user buys an item and they select the quantity. The current code im using is
$quantity = $_POST['quantity']; $sql = "Update item SET Stock = Stock - $quantity WHERE ProductId = $ProductId"; $result = mysql_query($sql) or die ( mysql_error() );
Any Help?
and what exactly is the problem?
the above code doesn't work and gives me an 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 'WHERE ProductId =' at line 1
I dont know how to fix it.
is $ProductId defined?
yea that was the problem, it was id not productid lol thanks for help