Forum Moderators: coopster

Message Too Old, No Replies

help with mysql_insert_id()

         

Smad

2:51 pm on Dec 20, 2004 (gmt 0)

10+ Year Member



Hi all

this is driving me mad now, basically i have a user table and a members table, when a member joins they set a password etc. Now i want the auto ID from user table to insert into members table when they create the account but it wont work....

$sql = "insert into user (foo) values
('$foo')";

printf("Last inserted record has id %d\n", mysql_insert_id());

This keeps giving me and ID of 0 but DB is auto incrementing?

Any ideas why i cant capture the insert ID..

TIA and Happy Xmas

Smad

Smad

3:18 pm on Dec 20, 2004 (gmt 0)

10+ Year Member



ok fixed it, was in the wrong place :D