Re: [PHP-DEV] Bug #416: mysql_insert_id() always returns 0 From: Zeev Suraski (bourbon <email protected>)
Date: 05/29/98

At 20:32 29/05/98 -0000, steve <email protected> wrote:
>From: steve <email protected>
>Operating system: Solaris2.6
>PHP version: 3.0 Release Candidate 5
>PHP Bug Type: MySQL related
>Bug description:
>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?

Hrm, are you sure you have an AUTO_INCREMENT field in your table?

Zeev

--
Zeev Suraski   <zeev <email protected>>
For a PGP public key, finger bourbon <email protected>