I read some previous posts in this forum about inserting records into multiple tables and adapted one suggestion with this:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO images (image_id, image) VALUES (%s, %s)",
GetSQLValueString($_POST['image_id'], "int"),
GetSQLValueString($_POST['image'], "text"));
mysql_select_db($database_Tr_adconr25_jut, $Tr_adconr25_jut);
$Result1 = mysql_query($insertSQL, $Tr_adconr25_jut) or die(mysql_error());
$new_image_id = mysql_insert_id();
$insertSQL = sprintf("INSERT INTO books_on_sale (image_id, teaser, book, author) VALUES ($new_image_id, %s, %s, %s)",
GetSQLValueString($_POST['image_id'], "int"),
GetSQLValueString($_POST['teaser'], "text"),
GetSQLValueString($_POST['book'], "text"),
GetSQLValueString($_POST['author'], "text"));
mysql_select_db($database_Tr_adconr25_jut, $Tr_adconr25_jut);
$Result1 = mysql_query($insertSQL, $Tr_adconr25_jut) or die(mysql_error())
;
My problem is that everything posts fine with the exception of the table ‘books_on_sale’ “teaser” field. It posts as NULL and I’m not sure why.
I’ve tried removing the “$new_image_id” and replacing it with ‘%s’ and the “teaser” field will get posted, but then the “image_id” field in the ‘books_on_sale’ table will post as NULL.
Can someone tell me where I’m going wrong?