jcjst21 Posted August 4, 2011 Share Posted August 4, 2011 Hello, I used the mysql_insert_id() command on another script i wrote, and it worked fine. I pretty much reused the same code on another script for another table and it doesn't seem to be working. Here is my code: $sql="INSERT INTO AllergyList(camperID, camperAllergy) VALUES ('$camperID', '$allergy')"; $result = mysql_query($sql,$con); $allergyID=mysql_insert_id(); $sql2="INSERT INTO camperAllergyReactions(camperAllergyID, camperAllergyReaction) VALUES ('$allergyID', '$reaction')"; the first INSERT statement populates the data fine into the Allergy table, but the mysql_insert_id() does not seem to be working in this script. Any help would be appreciated. Thanks, jcjst Link to comment https://forums.phpfreaks.com/topic/243756-help-with-mysql_insert_id/ Share on other sites More sharing options...
phpSensei Posted August 4, 2011 Share Posted August 4, 2011 Print out a mysql_error() and let me know what it says. Link to comment https://forums.phpfreaks.com/topic/243756-help-with-mysql_insert_id/#findComment-1251580 Share on other sites More sharing options...
jcjst21 Posted August 4, 2011 Author Share Posted August 4, 2011 I actually had a header statement right after the second insert function and had it before the fetch query. That's what was holding it up. I figured it out. Link to comment https://forums.phpfreaks.com/topic/243756-help-with-mysql_insert_id/#findComment-1251583 Share on other sites More sharing options...
phpSensei Posted August 4, 2011 Share Posted August 4, 2011 Roger. Marked as solved I guess.. Link to comment https://forums.phpfreaks.com/topic/243756-help-with-mysql_insert_id/#findComment-1251585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.