使用传递的变量

时间:2015-11-04 23:27:41

标签: php mysql

这个更新查询似乎在MySQL WorkBench中有效但是当它应用到我的php应用程序时不想工作...... $TotalSeats& $PerfID参数已经过测试,并输出了所需的数字。

这是一个小的语法错误还是我在这里错过了一个技巧?

$deductSeats = "UPDATE perf SET Seats=(SELECT SUM(Seats -'$TotalSeats')) WHERE PerfID = '$PerfID'";
            if (mysqli_query($conn,$deductSeats))
            {
                echo 'Query Worked!<br>';
            }
            else
            {
                echo 'Query Didnt Work<br>';
            }





$deductSeats = "deductSeats(`$TotalSeats`,`$PerfID`)";

1 个答案:

答案 0 :(得分:1)

您可以尝试:

$deductSeats = "UPDATE perf SET `Seats` = `Seats` - ".$TotalSeats." WHERE PerfID = ".$PerfID;

    if (mysqli_query($conn,$deductSeats)) {
        echo 'Query Worked!<br>';
    } else {
        echo 'Query Didnt Work<br>';
    }