ID: 31728 Updated by: [EMAIL PROTECTED] Reported By: godwizard at hotmail dot com -Status: Open +Status: Feedback Bug Type: MySQL related Operating System: Linux Fedora Core 2 PHP Version: 5.0.3 New Comment:
Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. Previous Comments: ------------------------------------------------------------------------ [2005-01-27 20:24:10] godwizard at hotmail dot com Very odd... The ID which mysql_insert_id is returning, comes from following class/function: function ddd_use() { global $db_dur_insert; $query = sprintf(" insert into stat_ddd_use (istuntoID, rotuID, resolution, request, aikaleima) values (%u, %u, %s, %s, %u)", sql_valid($_SESSION['stat']['istuntoID']), sql_valid($_SESSION['rotuID']), sql_valid($_COOKIE['users_resolution']), sql_valid($_SESSION['login_request']), sql_valid((time()))); if ( (isset($db_dur_insert)) && (isset($query)) ) { $db_dur_insert->query($query); unset($query); } } All code are in several classes. And there is more than 1 DB connection opened at same time. ------------------------------------------------------------------------ [2005-01-27 20:08:22] godwizard at hotmail dot com Description: ------------ mysql_insert_id return wrong ID. It will add new line to DB correctly but when using mysql_insert_id to get auto_increment value, it will return something odd. Reproduce code: --------------- function add_line() { global $db_insert; $aikaleima = time(); if ( (isset($_SESSION['admin']['rekisteriID'])) && (strlen($_SESSION['admin']['rekisteriID']) > 0) ) { $query = sprintf(" insert into rekisteri_rekisteriID (rekisteriID, oletus, lisatty, lisaaja) values (%s, 1, %u, %u)", sql_valid($_SESSION['admin']['rekisteriID']), sql_valid($aikaleima), sql_valid($_SESSION['user']['userID'])); if ( (isset($db_insert)) && (isset($query)) ) { $result = $db_insert->query($query); unset($query); } if ( (isset($result)) && (mysql_affected_rows() > 0) ) { $rekisterinro = mysql_insert_id(); } .... Expected result: ---------------- Example value should be 29171. Actual result: -------------- Value is 7618. And ID 7618 is already reserved in DB. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31728&edit=1