From: Operating system: Linux 2.6.34.6-54.fc13.i686 PHP version: 5.3.3 Package: MySQL related Bug Type: Bug Bug description:mysql_insert_id return 0
Description: ------------ When calling mysql_insert_id() after insert, php returns 0, but if queried "SELECT LAST_INSERT_ID()" it returns the right value. Test script: --------------- <?php mysql_connect("localhost","root",""); mysql_select_db("test"); mysql_query("INSERT INTO table VALUES('', 'TEST')"); echo "LAST-ID (Function): " . mysql_insert_id() . "\n"; $res = mysql_query("SELECT LAST_INSERT_ID() as LID"); $r = mysql_fetch_assoc($res); echo "LAST-ID (Query): " . $r['LID']; ?> Expected result: ---------------- LAST-ID (Function): 38 LAST-ID (Query): 38 Actual result: -------------- LAST-ID (Function): 0 LAST-ID (Query): 38 -- Edit bug report at http://bugs.php.net/bug.php?id=53152&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53152&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53152&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53152&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53152&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53152&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53152&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53152&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53152&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53152&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53152&r=support Expected behavior: http://bugs.php.net/fix.php?id=53152&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53152&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53152&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53152&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53152&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53152&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53152&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53152&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53152&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53152&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53152&r=mysqlcfg