|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-01-28 21:40 UTC] tony2001@php.net
[2005-01-30 00:45 UTC] godwizard at hotmail dot com
[2005-02-28 20:55 UTC] sniper@php.net
[2005-03-20 18:06 UTC] sniper@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 23:00:01 2025 UTC |
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.