RE: [PHP] mysql_insert_id

From: Date: Thu, 29 Jun 2000 11:31:24 +0000
Subject: RE: [PHP] mysql_insert_id
Groups: php.general 
Request: Send a blank email to php-general+get-3777@lists.php.net to get a copy of this message
I can duplicate the problem reported by delbono@dsc.it circa 2000-06-29 at 1:45:59 Namely, with a db where: create table my_test ( id smallint auto_increment not null, my_test_text varchar(30), primary key(id)); Then with a PHP script: <?PHP $dbname="mydb"; $connection="myhost"; $SQL="insert into my_test values (0,'This is a test')"; mysql_db_query($dbname,$SQL,$connection); $new_id=mysql_insert_id(); echo "New record ID=" . $new_id . "<BR>"; ?> The result will ALWAYS be New record ID=0 EVEN THOUGH the script also inserts new records every time it is executed. This is on RH 6.2, mysql 3.22.30, Apache 1.3.12, Php 4.01 on Intel. Dave Nuttall San Antonio, TX

« previous php.general (#3777) next »