The ID field in the mySQL database is an auto_increment primary key. The only value provided at INSERT is the drawing_name field, which will not be unique in this table. I will need to reference the ID field for the remainder of my program. Is there a way to get the value of the ID field when the new record is inserted?
Here is what I was trying:
$result = mysql_query("INSERT INTO $table VALUES ('', '".$drawing_name."')");
if (mysql_affected_rows($result) < 1){
$row = mysql_fetch_object($result);
print "drawing_id=$row->ID";
} else {
print "error=Could not create new drawing.";
}
The new record is inserted into my database correctly, and the ID field is automatically assigned; but this does not return the value of ID.
Any thoughts? Thanks in advance!