php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #416 mysql_insert_id() always returns 0
Submitted: 1998-05-29 16:32 UTC Modified: 1998-06-01 13:09 UTC
From: steve at eyekon dot com Assigned: rasmus (profile)
Status: Closed Package: MySQL related
PHP Version: 3.0 Release Candidate 5 OS: Solaris2.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: steve at eyekon dot com
New email:
PHP Version: OS:

 

 [1998-05-29 16:32 UTC] steve at eyekon dot com
I use the following code to insert a new row with
autoincrement field in mysql:

$query = "Insert into cart_user (uname,upass,email) ";
$query .= "values ('$uname','$upass','$email')";
$insert = mysql($database,$query);
$user_id = mysql_insert_id();

When I display $user_id, it is 0.

What am I doing wrong?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-06-01 13:09 UTC] rasmus
Confirmed to be user error.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 10 01:01:28 2025 UTC