Is this a bug ?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am trying to add a new row to a MySQL table using a stored procedure and  
then obtain the new id value. The rows are added and affected _rows returns  
1 confirming the statement worked however no insert_id value is returned.  
The results of running this script are:

New ID:0 New Rows:1

MySQL Code

CREATE TABLE testing (
   testname VARCHAR(25)

CREATE PROCEDURE `addtest`(_testname VARCHAR(25))
INSERT INTO testing (testname) VALUES (_testname)

PHP Code
      $testname = "McHenry";

  //Open the connection
  $mysqli = new mysqli("**********", "**********", "**********",  

      // create the statement
      $stmt = $mysqli->prepare("call addtest(?)");

      /* bind parameters for markers */
      $stmt->bind_param("s", $testname);

      /* execute query */

  //Return the status of the query and display
  Echo "New ID:$newid New Rows:$affected_rows";

  /* close statement */

  /* close connection */

Thanks in advance...

p.s. If this is a bug is it treated like a new comet etc, do they name it  
after you ?

Re: Is this a bug ?

Quoted text here. Click to load it

What happens if you try $mysqli->query("SELECT LAST_INSERT_ID();")?  That
should be equivalent.
- Tim Roberts,
  Providenza & Boekelheide, Inc.

Re: Is this a bug ?

Quoted text here. Click to load it

Works, thanks a million...

Does this mean I get a bug named after me ?
I've decided to call it Zorgon !  

Site Timeline