Re: mysql_insert_id

From: Date: Tue, 26 Sep 2000 22:38:19 +0000
Subject: Re: mysql_insert_id
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-17698@lists.php.net to get a copy of this message
"Boget, Chris" wrote: > 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). All I mean is this is how it works for me, you need the result of mysql_connect() not the mysql() function. example: <?php $li = mysql_connect('localhost','user','pass'); @mysql_select_db('db'); mysql("db","INSERT INTO table VALUES ( '', '', '')"); $id = mysql_insert_id($li); ?> $li now holds the mysql link identifier that mysql_insert_id() is looking for. Regards, Joseph

« previous php.general (#17698) next »