0
I have the following query:
$ad="INSERT INTO comanda_aberta set numero='$a', data_abertura=NOW(), data_fechamento=NULL";
mysqli_query($con,$ad);
$idcomandalast = mysqli_insert_id($con);
when I print the variable $idcomandalast
it always returns empty. and in the database the Insert information is being recorded normally. someone can help me in this problem?
Does your database use autoincrement? Test like this
mysqli_query($con,$ad) or die(mysqli_error($con)); $idcomandalast = mysqli_insert_id($con); var_dump($idcomandalast);
– Guilherme Nascimento
return this Aki D: www server bar Sig pages 4 commands.php:10:int 10
– Jasar Orion
So it seems that returned correctly
int 10
, you must be overwriting the variable elsewhere in the script– Guilherme Nascimento
Then I realized this just that I commented on the var_dump line and gave an echo $idcomandalast; and it returned.
– Jasar Orion
As I said, your variable is being affected by something, probably being overly sensitive, has how to post more code?
– Guilherme Nascimento
face what I’m finding strange he that don’t have Cod, only the connection with db , if I give a print_r or var dump it shows the id if I give an echo or print it doesn’t show.
– Jasar Orion
You’re not messing with Buffer, are you?
– Guilherme Nascimento