I know it's depreciated, and not generally good practice. But this command: mysql_insert_id for some reason is returning this weird number. And it never has done before.
I cannot find reference to this number anywhere. For instance, I just inserted a record into id
:2, and it gives me the number 1587.
Where is getting that from?
I've had to resort to reverse-querying the database with the exact values that i've just pulled out of it to get the ID. But this makes no sense.
Edit Sorry if I didnt explain this; but it is just a standard insert statement:
INSERT INTO `job` (`subject`,`deadline`,`status`) VALUES ('$title','3454354','CREATED');
And the autoincrement is on the PK which is called 'id'.
The field id
results in being set to 2
, but mysql_insert_id
returns an odd number. I ran a table status and it shows the auto_increment to be as expected. I am not inserting anything else in this time. Literraly straight after I insert it I am querying for the last inserted ID.
chceck AUTOINCREMENT
col before inserting, and after
SHOW TABLE STATUS FROM `db_name` WHERE NAME='col_name';
EDIT: You can see in "create table" if You have huge start number.
Maybe You have Trigger on this table ?
the manual says mysql_insert_id returns:
The ID generated for an AUTO_INCREMENT column by the previous query on success, 0 if the previous query does not generate an AUTO_INCREMENT value, or FALSE if no MySQL connection was established.
do you have auto increment on?