RE: [PHP] mysql_insert_id()

From: Date: Wed, 24 Jan 2001 21:49:22 +0000
Subject: RE: [PHP] mysql_insert_id()
Groups: php.general 
Request: Send a blank email to php-general+get-36489@lists.php.net to get a copy of this message
> You probably stated this in your previous post, but what is > the result from your call to mysql() ? Is this call failing so > that when you get to mysql_insert_id(), the id doesn't exist? I did. It's returning a numerical one (1). What I'm doing now is as follows. It's getting me the value but I'm so afraid that if 2 queries get sent almost simultaneously it's going to screw everything up... $link = mysql_pconnect( "localhost", "thisuser", "thatpass" ); $result = mysql( $dbname, $dbquery ); $id = mysql_insert_id( $link ); if( !$id ) { $id = mysql_insert_id(); } if( !$id ) { $insertIDQuery = "SELECT last_insert_id()"; // get values from above query, etc., etc. } You get the gist of it... I cannot believe this stupid thing won't work otherwise... And it's not consistent when it works and doesn't. Very odd. *sigh* Chris

« previous php.general (#36489) next »