RE: [PHP] mysql_insert_id

From: Date: Tue, 26 Sep 2000 13:42:06 +0000
Subject: RE: [PHP] mysql_insert_id
Groups: php.general 
Request: Send a blank email to php-general+get-17611@lists.php.net to get a copy of this message
> > 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? > mysql() function ? Do you mean mysql_connect() as that is > what you need the return value from. mysql_connect() "connects" to the mysql database. mysql() runs the query. mysql_insert_id() does not work on the result returned by mysql_connect() (if any is returned) because there is no way that it can know what the auto_increment value is w/o having a query run. I think perhaps you meant: mysql_query(). If that is the case, mysql() is essencially the exact same function except that it requires that the name of the db get passed (where mysql_query() does not). Chris

« previous php.general (#17611) next »