mardi 9 juillet 2019

no matter what I do, always 1 is smaller than 0

The following code returns 1 and when I compare it with 0, it returns false. It does not makes any sense...

function CheckMAG($newmac, $con) {
    LogToFile("Renew","CheckMAC",$newmac);
    $encMAC = base64_encode(strtoupper($newmac));
    LogToFile("DebugFile","CheckMAG Encripted",$encMAC);
    $resultmag_devices = mysqli_query($con, "SELECT `id` FROM `mac_devices` WHERE `mac`='{$encMAC}");
    LogToFile("Renew","CheckMAC Results",print_r($resultmac_devices));
    $sqlResults = intval(mysqli_num_rows($resultmac_devices));
    if ($sqlResults > 0) {
        LogToFile("DebugFile","SQLResults is","BIGGER");
        $return = TRUE;
    }else{
        LogToFile("DebugFile","SQLResults is","SMALLER");
        $return = FALSE;
    }
    return $return;
}

When I run the query manually, it returns 1 row. The log shows:

1562685478 Executing CheckMAC: Values are: '00:1A:79:3B:01:AD'
1562685478 Executing CheckMAC Encripted: Values are: 'MDA6MUE6Nzk6M0I6MDE6QUQ='
1562685478 Executing CheckMAC Results: Values are: '1'
1562685478 Executing SQLResults is: Values are: 'SMALLER'
1562686000 Executing Renew DanutStoica-x2 : Values are: 'streamline'
1562686000 Executing Checking custom fields for DanutStoica-x2 : Values are: '1'

I do not know what else to try... can I have some help out here please.

i tried with intval and without, same result. there is no error message showing up. i expect 1 to be bigger than 0 as expected from comparing 2 integers.

Aucun commentaire:

Enregistrer un commentaire