I have to increment a field in my DB each time I execute this statement:
$sql="UPDATE `product` SET buyCount = buyCount+1 WHERE id=".$productID;
But it doesn't work. Any help ?
My best guess would be that BuyCount is initialized to NULL and not 0. Try:
set BuyCount = coalesce(BuyCount, 0) + 1
Alternatively, your where clause is failing. You might try setting a value in another column to see if it is working.
将结束 " 移动到查询的末尾并将变量括在单引号中。
$sql="UPDATE product SET buyCount = buyCount+1 WHERE id='$productID'";
试试这个
$sql="UPDATE product SET buyCount = buyCount+1 WHERE id= $productID";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.