-1
I’m trying to make a return "Registration made successfully" but always falls in Else, he is not counting the number of lines.
public function adicionarAluno(string $nome, string $matricula, string $endereco, string $tel): void{
$adicionar=$this->mysql->prepare("INSERT INTO aluno (nome,matricula,endereco,tel) VALUES (?,?,?,?);");
$adicionar->bind_param('ssss',$nome,$matricula,$endereco,$tel);
$adicionar->execute();
$teste=$adicionar->num_rows;
if($teste > 0){
echo "<script>alert('Cadastro realizado com sucesso!');</script>";
}else{
echo "<script>alert('Falha!');</script>";
}
}
replaces $add->num_rows for $add->affected_rows
– user142154
Thank you very much, now it’s working!!
– Medivh