Re: #23214 [NEW]: mysql_insert_id - Never use the function "Blank"

From: Date: Tue, 15 Apr 2003 11:27:47 +0000
Subject: Re: #23214 [NEW]: mysql_insert_id - Never use the function "Blank"
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969352606@lists.php.net to get a copy of this message
On Tue, 2003-04-15 at 00:31, Philip Olson wrote: > On 14 Apr 2003, Andrew Lindeman wrote: > > Is this really a bug? I think it's just a confused user, but I want to > > be sure before making it bogus. > > It's hard to say and in some ways doesn't even matter > because it appears his problem exists in 4.1.2 but > doesn't in 4.3.0 so even if it was a bug, it's been > fixed. Although, ideally if resource became optional > fairly recently we'd have a <note> on when that > happened, that would be standard procedure. So, you > may want see if that's the case here ;) > > On a related note, here's a user comment found at > php.net/mysql-insert-id > > "Note that if you have more than one database link > open, you need to tell it which one you want the > last insert ID for, MySQL won't guess." > > IF that's true then it'd be a phpdoc bug as the docs > make it seem the most recent of the two connections > would be used. I guess one of the ext/mysql guys would > have to clarify. Also, in this scenerio, Stefan might > be using two connections... > > Regards, > Philip > I was thinking it might be the last _opened_ connection, not the last _used_ connection (could be wrong, but that sounds logical). However, PHP version could be to blame also... --Andrew > > > > On Mon, 2003-04-14 at 17:20, Stefan_255 at hotmail dot com wrote: > > > From: Stefan_255 at hotmail dot com > > > Operating system: win2k > > > PHP version: 4.3.0 > > > PHP Bug Type: Documentation problem > > > Bug description: mysql_insert_id - Never use the function "Blank" > > > > > > I copied a few lines of code from the net and got it to work in my own test > > > environment. When I placed the software on the production server (linux > > > PHP 4.1.2) - it only "almost" worked. > > > The problem was that it had lines with statements like: > > > > > > mysql_insert_id(); > > > > > > where strange id's sometimes were returned ! > > > > > > Then, when I changed the code to: > > > > > > mysql_insert_id($con); // The resource link_identifier > > > > > > everything was fine. I believe that what happened was that my program > > > received id's from somebody else doing INSERT on the same server? > > > > > > My conclusion was: > > > > > > Never use the function without the > > > "resource link_identifier" ! > > > > > > And then again, - Why should you? > > > > > > In the documentation it says:"If link_identifier isn't specified, the last > > > opened link is assumed." > > > > > > My code was simply: > > > > > > $sql= "INSERT INTO xrefs (referrer) VALUES ('$ref')"; > > > echo "sql $sql <br>"; > > > $result = mysql_query($sql,$con); > > > //$referrer_id = mysql_insert_id(); // FAILED > > > $referrer_id = mysql_insert_id($con); // WORKED OK > > > > > > > > > > > > -- > > > Edit bug report at > > > http://bugs.php.net/?id=23214&edit=1 > > > -- > > > Try a CVS snapshot: > > > http://bugs.php.net/fix.php?id=23214&r=trysnapshot > > > Fixed in CVS: > > > http://bugs.php.net/fix.php?id=23214&r=fixedcvs > > > Fixed in release: > > > http://bugs.php.net/fix.php?id=23214&r=alreadyfixed > > > Need backtrace: > > > http://bugs.php.net/fix.php?id=23214&r=needtrace > > > Try newer version: > > > http://bugs.php.net/fix.php?id=23214&r=oldversion > > > Not developer issue: > > > http://bugs.php.net/fix.php?id=23214&r=support > > > Expected behavior: > > > http://bugs.php.net/fix.php?id=23214&r=notwrong > > > Not enough info: > > > http://bugs.php.net/fix.php?id=23214&r=notenoughinfo > > > Submitted twice: > > > http://bugs.php.net/fix.php?id=23214&r=submittedtwice > > > register_globals: > > > http://bugs.php.net/fix.php?id=23214&r=globals > > > PHP 3 support discontinued: > > > http://bugs.php.net/fix.php?id=23214&r=php3 > > > Daylight Savings: > > > http://bugs.php.net/fix.php?id=23214&r=dst > > > IIS Stability: > > > http://bugs.php.net/fix.php?id=23214&r=isapi > > > Install GNU Sed: > > > http://bugs.php.net/fix.php?id=23214&r=gnused > > -- > > Andrew Lindeman <alindeman@php.net> > > > > > > -- > > PHP Documentation Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- Andrew Lindeman <alindeman@php.net>

« previous php.doc (#969352606) next »