Re: mysql_insert_id?

From: Date: Wed, 16 Jan 2002 18:02:58 +0000
Subject: Re: mysql_insert_id?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-80773@lists.php.net to get a copy of this message
Hi mike, >>>> last_insert_id() will return you the last inserted ID from >>>> previous 'session', not current 'session'. >>>> to prevent this, you should call last_insert_id() only when >>>> your INSERT query executed succesfully. >> Most probably the returned value would be wrong, because it will >> return the last_insert_id of previous INSERT query (from previous >> 'session') > but of course, you'd have checked that the result id returned a valid result > and not an error in this case and never looked for the last_insert_id, Exactly. That's why in the first posting (read the first paragraph above), I told him to exec last_insert_id() or mysql_insert_id() ONLY when the insert query is SUCCESSFUL. -- Jimmy ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When you lose, don't lose the lesson.

« previous php.general (#80773) next »