RE: [PHP] mysql_insert_id

From: Date: Tue, 26 Sep 2000 13:22:28 +0000
Subject: RE: [PHP] mysql_insert_id
Groups: php.general 
Request: Send a blank email to php-general+get-17609@lists.php.net to get a copy of this message
> > I'm inserting data into a table with an auto_increment > > field. The data is going in perefectly (with the A_I field > > incrementing as it should; I can see this is true in the DB) > > and there is no errors being returned. > > However, when I try to executed the mysql_insert_id() > > function (immediately after the query), it is returning > > '0' (zero). Why? > > Here is my field definition: > > | ticket_number | int(15) unsigned | | PRI | 0 | > > auto_increment | > > I cannot see in the docs why it would fail and unfortunately, > > mysql_insert_id() does not return why it would have failed > > getting the auto_increment value. > > I'm using PHP 3.0.5 and any help anyone could offer would > > be greatly appreciated!! > Try calling the mysql_insert_id($dbh) where $dbh is the link > identifier from the mysql_pconnect() or mysql_connect() > function. Update: when I pass the result returned by the mysql() function call, mysql_insert_id() returns '0' (zero). But when I do not pass any arguments to the mysql_insert_id() function, it returns the correct value. Why? Shouldn't it work properly either way? Chris

« previous php.general (#17609) next »