Instead of checking if(!$id), perhaps you would be better off to check the
result of your query (which in this example was successful, since you got a
return from mysql() ).
Also, what is the last_insert_id() function that you are referencing in your
$insertIDQuery string?
As for things getting messed up when two queries hit the system at the same
time, you shouldn�t need to worry about that either because the two people
coming in would have different values for the $link variable and since
mysql_insert_id goes off of the link identifier of the connection (which
will be different for the two different people running queries), you should
not have a conflict.
HTH
Sam Masiello
Systems Analyst
Chek.Com
(716) 853-1362 x289
[EMAIL PROTECTED]
-----Original Message-----
From: Boget, Chris [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 24, 2001 4:49 PM
To: 'Sam Masiello'; Php (E-mail)
Subject: RE: [PHP] mysql_insert_id()
> 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