php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10138 mysql_insert_id() returns incorrect value
Submitted: 2001-04-03 11:20 UTC Modified: 2001-04-03 13:23 UTC
From: jules at acris dot co dot uk Assigned:
Status: Closed Package: MySQL related
PHP Version: 4.0.4pl1 OS: linux 2.2
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jules at acris dot co dot uk
New email:
PHP Version: OS:

 

 [2001-04-03 11:20 UTC] jules at acris dot co dot uk
Example script:

mysql> use test;
mysql> create table mytable (a int primary key auto_increment, b int, c int);

<?php
        mysql_connect("localhost","root","bannerjee");
        mysql_select_db("test");
        mysql_query("insert into mytable values (null, 5, 6)");
        echo mysql_insert_id();
        $res = mysql_query("select last_insert_id()");
        $row = mysql_fetch_row($res);
        echo "<BR>$row[0]";
        ?>

Example output:

722
8

Mysql 2.23.33; using the library provided with mysql (ie configure --with-mysql=/usr).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-03 11:25 UTC] rasmus@php.net
I tested on 2 boxes using your exact script.  Works perfectly.  If this was broken thousands of scripts out there wouldn't work.  Check that your libmysqlclient version matches your mysql server version.
 [2001-04-03 13:12 UTC] jules at acris dot co dot uk
Information from the RPMs of the MySQL packages:

[root@fddth03-157-31 /root]# rpm -q -i -f /usr/lib/libmysqlclient.so.10.0.0
Name        : MySQL-shared                 Relocations: (not relocateable)
Version     : 3.23.33                           Vendor: (none)
Release     : 1                             Build Date: Fri Feb  9 02:42:35 2001
Install date: Thu Mar  8 20:05:07 2001      Build Host: mysql-work
Group       : Applications/Databases        Source RPM: MySQL-3.23.33-1.src.rpm
Size        : 437510                           License: GPL / LGPL
Packager    : David Axmark <david@mysql.com>
URL         : http://www.mysql.com/
Summary     : MySQL - Shared libraries

[root@fddth03-157-31 /root]# rpm -q -i -f /usr/bin/mysql
Name        : MySQL-client                 Relocations: (not relocateable)
Version     : 3.23.33                           Vendor: (none)
Release     : 1                             Build Date: Fri Feb  9 02:42:35 2001
Install date: Thu Mar  8 20:06:03 2001      Build Host: mysql-work
Group       : Applications/Databases        Source RPM: MySQL-3.23.33-1.src.rpm
Size        : 2697037                          License: GPL / LGPL
Packager    : David Axmark <david@mysql.com>
URL         : http://www.mysql.com/
Summary     : MySQL - Client

[root@fddth03-157-31 /root]# rpm -q -i -f /usr/sbin/mysqld
Name        : MySQL                        Relocations: (not relocateable)
Version     : 3.23.33                           Vendor: (none)
Release     : 1                             Build Date: Fri Feb  9 02:42:35 2001
Install date: Thu Mar  8 19:49:49 2001      Build Host: mysql-work
Group       : Applications/Databases        Source RPM: MySQL-3.23.33-1.src.rpm
Size        : 14793480                         License: GPL / LGPL
Packager    : David Axmark <david@mysql.com>
URL         : http://www.mysql.com/
Summary     : MySQL: a very fast and reliable SQL database engine
Description :

As you can see, these are all from the same source & version so there should not be any compatibility issues.

Has anyone tried this with the same version of mysql? is it a version incompatibility problem?

When compiling php I used ./configure --with-mysql=/usr ...

 [2001-04-03 13:23 UTC] jules at acris dot co dot uk
OK; I just tested with the mysql C interface and that didn't work right either, so I guess I'll take this over to mysql.  Sorry to bother you fine folks!

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC