This Update Query seems to work inside MySQL WorkBench but when applying it to my php application doesn't want to work... Both the $TotalSeats
& $PerfID
parameters have been tested and they output the desired number.
Is this a minor syntax error or am I missing a trick here?
$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`)";
You can try :
$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>';
}