Page 1 of 1

mysql_insert_id() help

Posted: Thu Jun 05, 2003 8:36 pm
by glennn
i'm passing an AUTO_INC. from one table to the form on the next page using "/page.htm?subscriberID=".$subscriberID and it's passing the variable to the next url correctly, but writing "0" in my table - can someone help, please?


thanks,
glenn

Posted: Fri Jun 06, 2003 1:22 am
by delorian
Could you givel more details :? There's probably a mistake in query, but I can't tell...

Posted: Fri Jun 06, 2003 1:53 am
by glennn
mysql_query($query);
$SubscriberID=mysql_insert_id();
header("Refresh: 0;url=http://www.safe-teen.net/autoreg.php?Su ... bscriberID);

i do this and it once was passing the AUTO_INCREMENTED int friom the first table to the url so i could use it in a second form, but it suddenly started passing "0" always. can't figure out why...

i think it's someting to do with the indices and the primary keys in the tables because i was fooling around with them to make it work before...

thanks

Posted: Fri Jun 06, 2003 2:17 am
by delorian
If mysql_insert_id() doesn't return a value, there must be something wrong with your database.

Echo the mysql_insert_id() before the refresh and see if there's something (also commnet the header for test purposes). If it doesn't work, try using a database query SELECT LAST_INSERT_ID().