I am new to PHP and prepared SQL sentences and I got one question when reading the documentation.
Function 'mysqli.prepare' returns a boolean value when executed. According to the documentation:
mysqli_prepare()
returns a statement object or FALSE if an error occurred.
That's not a very detailed description of the returned value. I mean, when does it exactly fail? Only when the SQL syntax is not correct? Or when we try to execute it and it does not work for any other reason (I base this last supposition on the example shown on the documentation, where almost all the script is enclosed in an if
statement)
Based on this, I also have a second question: is it a good practice to run mysqli_prepare()
together with an if
? Or should the if
statement be written when we run the $stmt->execute();
function later on?