Let say I have this code:
$conn=new mysqli($host,$user,$pass,$dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO login (username, password)
VALUES ('$username','$password')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
In second IF statement I checked out if $conn->query($sql) === TRUE. This code works although I didn't previously execute $conn->query($sql). In this IF statement, PHP executes the command and checks out if it is executed at the same time. What if I only want to check not execute? In what circumstances you can execute a command in IF statement and in what you only check if it is previously done.
Aucun commentaire:
Enregistrer un commentaire