Decrementing a column - code not working
-
I was told this would work, but it is not. I do not know the value in a particular column, but I want to decrease it by a number. In other words, Dude buys 2 widgets, the inventory of said widget gets reduced by two.
$u_sql='UPDATE sale_inventory SET invqty = invqty - '.$boughtqty.' WHERE invProdID='.$row['ProdID'];
This yields an SQL Statement like:
UPDATE sale_inventory SET invqty = invqty - 1 WHERE invProdID=1234567
I cannot tell why this is not working. Thanks in advance.
***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
-
I was told this would work, but it is not. I do not know the value in a particular column, but I want to decrease it by a number. In other words, Dude buys 2 widgets, the inventory of said widget gets reduced by two.
$u_sql='UPDATE sale_inventory SET invqty = invqty - '.$boughtqty.' WHERE invProdID='.$row['ProdID'];
This yields an SQL Statement like:
UPDATE sale_inventory SET invqty = invqty - 1 WHERE invProdID=1234567
I cannot tell why this is not working. Thanks in advance.
***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
The SQL looks fine. Could you show the PHP code that executes the SQL?
-
I was told this would work, but it is not. I do not know the value in a particular column, but I want to decrease it by a number. In other words, Dude buys 2 widgets, the inventory of said widget gets reduced by two.
$u_sql='UPDATE sale_inventory SET invqty = invqty - '.$boughtqty.' WHERE invProdID='.$row['ProdID'];
This yields an SQL Statement like:
UPDATE sale_inventory SET invqty = invqty - 1 WHERE invProdID=1234567
I cannot tell why this is not working. Thanks in advance.
***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW
do you have an error message, can you use something like.. $rst = mysql_query($u_sql) or die(mysql_error()); this will print the message coming from the mysql db.
Chris J www.redash.org
-
do you have an error message, can you use something like.. $rst = mysql_query($u_sql) or die(mysql_error()); this will print the message coming from the mysql db.
Chris J www.redash.org
Thanks for the replys... I have error checking
$u_result = @mysql_query($u_sql, $link_b);
if (!$u_result) { exit('Error reducing inventory: ' . mysql_error() . '
');}
There is no error thrown, just that value is not reduced. Like an idiot, when scrubbing my data, I probably should have left it... My invProdID has - marks in them, so I needed quotes around them. Total newb error. Thank you both anyway. You assurances that it seemed right made me think down the typo path.
***************** "We need to apply 21st-century information technology to the health care field. We need to have our medical records put on the I.T." —GW