0
Good afternoon guys, first thanks for helping me, I’m finishing a system and I have a problem that I believe is very simple, but I can not solve, I tried several ways to change the if, but will not
the code is this
public function verificavenda(){
$c= new conectar();
$conexao=$c->conexao();
$sql="SELECT idvenda from vendas order by idvenda desc";
$result=mysqli_query($conexao,$sql);
$id=mysqli_fetch_row($result)[0];
if($id == "" or $id == null or $id == 0){
return 1;
}else{
return $id + 1;
}
}
after the first $id created, it always falls on Isis, until then beauty, is what wanted
now when you have nothing in the database, give the following error > "trying to access array offset on value of type null"
and instead of falling into IF falls into Else in the same way, returning an error on the page instead of returning only the number
I’ve already lost a few hours, and I can’t find the train, thank you!
good diaa worked perfectly, I will, but I would like to thank you even for having answered me the error, at least with this error I will not suffer more thank you my king!
– user205828
Arrange... We are here to help. If you can mark the answer as accepted, thank you.
– Marcos Alexandre