I have two tables in my db. One table contains portfolio images with a primay key set to AI. The other table contains all of the thumbnails that need to be associated with each portfolio image with no primary key. I'm trying to grab the last inserted id of the portfolio image and enter it into my table of thumbnails so each group of thumbnails is associated to the correct portfolio image by the id. I'm using the following code:
if (isset($_POST['btnSubmit'])) {
//...........
foreach ( $_FILES['small_tn_']['name'] as $key=>$value1 )
{
$smallImage=$_FILES['small_tn_']['name'][$key];
$largeImage=$_FILES['large_image_']['name'][$key];
$overlay_id= mysql_insert_id();
$sql_overlay = sprintf("INSERT INTO 'overlay'('overlay_id','small_tn','large_img') VALUES ('%s','%s','%s')",$overlay_id,$smallImage, $largeImage );
$db->query($sql_overlay);
}
}
//............
}
...to insert values from a form with dynamic fields into my db. When I don't have this line included (along with the corresponding variables):
$overlay_id= mysql_insert_id();
...everything submits fine with the exception of the id of course. When that line of code is included (along with the corresponding variables): I receive this error:
Query failed: INSERT INTO 'overlay'('overlay_id','small_tn','large_img') VALUES ('82','imagine_tn01.jpg','imagine-full.jpg')
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''overlay'('overlay_id','small_tn','large_img') VALUES ('82','imagine_tn01.jpg','' at line 1"
Could somebody please give me insight as to what I'm doing wrong? I'm a newb so I'm learning as much as I can. I hope I explained everything clearly.
Thanks for the help...