I am doing an insert into a mysql table with an autoincrementing id. I then need to insert that newly generated id into a different table. Here's the code I have at this point:
MySQL_query("insert into database.table_1(field1, field2, field3, field4) values ('$var_1, '$var_2', '$var_3', '$var_4');");
$sqlId = "Select id from database.table_1 where field1 = '$var_1'";
$sqlNewId = MySQL_query($sqlId);
$row = mysql_fetch_array($sqlNewId);
$strNewId = $row["Id"];
MySQL_query("insert into database.table_2(field1, field2, field3, field_id) values ('text', '$var_5', '$var_6','$strNewId');");
everything works, except that the id that gets inserted into table_2.field_id is always 0. The id is getting set in the first table, so I don't get why this isn't working.
Any help would be appreciated.