> Why not split it into 2 forms? insert, then attach pictures to the record.
Its just not user-friendly enough, I have thought about it though. I think I'd rather risk the script hitting an error than compromise the user-friendliness.....after all, the chance of a file not saving is miniscule as I can guarantee no other file will exist with that name....and for the sql to fail would probably mean the DB server being offline which would mean the user would never even get to the form in the first place. > Otherwise, decide what's the key issue (imho the a record can exist without > pics, but not vice-versa), and focus on that first. I see where your coming from but it can happen vice-versa. I assign the image a name in the format "pic<?= $userid ?>_<?= $usercount ?>.gif" so if the users id is 12 and that user already has 12 images, the filename would be pic12_13.gif. These names are then stored in the 'Pictures' table. This is how the logic might go (assuming user id 12): 1. SELECT CurrentPictureNum FROM Users WHERE UserID = 12 -- CountPictureNum never gets decremented 2. loop $_FILES and count number of images (don't save yet) 3. UPDATE Users SET CountPictures = CountPictures + <?= $number_of_new_images ?> -- this guarantees no files in the future will overwrite -- the ones which are about to be saved 4. loop $_FILES again but this time save them 5. INSERT INTO Items VALUES (......) -- if it fails here, who cares, it just means images are -- stored which don't need to exist, i can write a cleanup -- script to deal with these though 6. loop over array of names of new images and INSERT INTO Pictures VALUES (....) -- this is the only dodgy bit, if we fail here the Items -- record has been created but the script fails. I think -- however its fair to assume though that if the first -- insert worked, these will too. Opinions? Thanks, Jim. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php