Just to know what is hoing on, I would do a couple changes:
while ($dbRow=$dbQuery->fetch(PDO::FETCH_ASSOC)) {
$points = $dbRow['Points'];
$pointsDeduction =-20;
}
if($daysLeft == $End) {
$stmt = $conn->prepare("UPDATE Profile SET Points = $points - $pointsDeduction WHERE UserID= $UserID WHERE UserID= $UserID");
$dbQuery->execute();
echo" - 20 points will be deducted</h4></center></h4>";
}
This "$points - $pointsDeduction" translate to "$points - -20" and to "$points + 20".
Are you sure about it ?
Your SQL command repeat the where clause 2 times.
I would change the sql command to smething like:
$stmt = $conn->prepare("UPDATE Profile SET Points = Points - 20 WHERE UserID= $UserID");
-----
Learn to indent properly your code, it show its structure and it helps reading and understanding. It also helps spotting structures mistakes.
while ($dbRow=$dbQuery->fetch(PDO::FETCH_ASSOC)) {
$points = $dbRow['Points'];
$pointsDeduction =-20;
}
if($daysLeft == $End) {
$stmt = $conn->prepare("UPDATE Profile SET Points = $points - $pointsDeduction WHERE UserID= $UserID WHERE UserID= $UserID");
$dbQuery->execute();
echo" - 20 points will be deducted</h4></center></h4>";
}
Professional programmer's editors have this feature and others ones such as parenthesis matching and syntax highlighting.
Notepad++ Home[
^]
ultraedit[
^]