Hiya,
Which of these IF CONDITION codes are valid ?
And can you rank the valid ones according to your choice by giving reasons to your choices ?
Thanks!
$conn = mysqli_connect("localhost","root","","buzz");
$sql = "INSERT into users (username,email) VALUES (?,?)";
if($stmt = mysqli_prepare($conn,$sql))
{
mysqli_stmt_bind_param($stmt,"ss",$_POST[username'],$_POST['email']);
if(!mysqli_stmt_execute($stmt)) //FIRST CHOICE
if(mysqli_stmt_execute($stmt)==FALSE) //IS THIS VALID ? RECKON VALID. SECOND CHOICE
if(mysqli_stmt_execute($stmt)===FALSE) //IS THIS VALID ? RECKON VALID. BUT POINTLESS.
if(mysqli_stmt_execute($stmt)!=TRUE) //IS THIS VALID ? 5TH CHOICE
if(!mysqli_stmt_execute($stmt)!==TRUE) //IS THIS VALID ? RECKON VALID. BUT POINTLESS.
if(mysqli_stmt_execute($stmt)==NULL) //IS THIS VALID ?
if(!mysqli_stmt_execute($stmt)===NULL) //IS THIS VALID ?
if(mysqli_stmt_execute($stmt)==0) //IS THIS VALID ? RECKON INVALID.
if(!mysqli_stmt_execute($stmt)===0) //IS THIS VALID ? RECKON INVALID.
if(mysqli_stmt_execute($stmt)<1) //IS THIS VALID ?
if(mysqli_stmt_execute($stmt)!=1) //IS THIS VALID ?
if(mysqli_stmt_execute($stmt)!==1) //IS THIS VALID ?
{
echo 'Something went wrong! Please notify webmaster following error!';
die('Error 2!');
}
else
{
die('Thank you for your submission!)';
}
}
else
{
echo 'Something went wrong! Please notify webmaster following error!';
die('Error 1!');
}
Q1: Which of my choices are incorrect and why ?
Q2. Out of the valid IF CONDITIONS, can you rank them according to most valid on top and least valid on bottom ? This should teach me best practice.