mardi 5 septembre 2017

PHP if statement comparison always returning true

My if statement is always returning true, and I cannot chase the problem.

The value of $currentMessageCount is 42, and lastMessageCount is 41.

$result = $mysqli->query("SELECT message_count, last_seen
                          FROM message_counter 
                          WHERE match_id = '$i'");
$row = $result->fetch_assoc();
$currentMessageCount = (int)$row["message_count"];
$lastMessageCount = (int)$row["last_seen"];
$result->free();

if ($currentMessageCount > $lastMessageCount) {

    this code is running

} elseif ($currentMessageCount === $lastMessageCount) {

    this code is also running!!

}

Aucun commentaire:

Enregistrer un commentaire