dimanche 16 août 2020

PHP - Can if-statement being ignored/skipped for some reason?

What I want to achieve : if a user pass a PHP parameter to the server, it will return the same parameter value back to the user, instead of returning the value from the database itself.

while($row = mysqli_fetch_assoc($result)){
    $classId = $row['classId'];
    
    if($obj['classId'] != ""){
        $classId = $obj['classId'];
    }

...
}

For some reason, I found out that the $classId still using the $row['classId'] value, even if the user had inserted the classId parameter. It seems that the PHP has ignored/skipped the if statement.

 if($obj['classId'] != ""){..} //SKIPPED?

The code works fine right now and I do get the return of the same parameter value. Only one user out of hundreds got this issue and I assumed that the he/she had sent the parameter when the server was busy.

Questions:

1.Can if-statement being ignored/skipped for some reason? 2.How to make the if-statement more reliable even if the server in a high-traffic?

Excuse me for posting here. I don't find the right keywords for googling myself.

Thank you.

Aucun commentaire:

Enregistrer un commentaire