1
I have the following code snippet:
public function registerUser($link, $nome, $sobrenome, $apelido) {
$sql = "INSERT INTO estudo_oo (id, nome, sobrenome, apelido) VALUES ('', '$nome', '$sobrenome', '$apelido') ";
if(!mysqli_query($link, $sql)) {
die('Error: ' . mysqli_error($link));
}
}
And my question is: Would I have to ALWAYS pass the variables by parameter there in the function? Because like, if I had a form with multiple fields for example, I would actually have to pass all variables there?
I did some tests and tried to save the form without passing the variables by parameter, but I was not successful, then I came up with this question.
Hit a question: passing a null variable in a Prepared statement will insert the null value in the bank or a
string
empty?– gmsantos
If you use
bind_param
and passnull
, the valueNULL
will be inserted.– bfavaretto