I am inserting data into one table where an auto_increment id is formed. I want to place this same id into a second table. I have tried using mysql_insert_id and last_insert_id but always get a "0". The first table is incrementing as it should, but I can't seem to capture this value.
Any thoughts?
I have read and tried suggestions from mysql and php.
Ron
How to make mysql_insert_id work
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Are you calling the function directly after the query because even a line or two of code inbetween may stop it working.php.net wrote:mysql_insert_id() returns 0 if the previous query does not generate an AUTO_INCREMENT value. If you need to save the value for later, be sure to call mysql_insert_id() immediately after the query that generates the value.
Mac