Hi,

I have the following scenario:

A user can login to my website (so I know their ID) and create a new 'item
record' through a form. This item may have up to 10 images uploaded with it
(pictures of the item). The structure of my DB is a main 'Items' table
holding textual description/price/location information of the item and
another table 'Pictures' holding information on each image uploaded. My
problem is how to handle an error if something goes wrong i.e. sql insert
fails or the file copy() fails.

What I don't want to happen is for the 'Items' record to be created and then
1 or more files fail to upload. So I thought, I'll upload the files first,
but the problem with this is that in the 'Pictures' table I have to enter an
'ItemID' field obviously to link the pictures to the item, but the ID of the
item isn't known as it hasn't been created yet. Ahhhhhh!!

My next thought was to upload the files first, then insert the 'Items'
record, then insert the multiple 'Pictures' records.....I figure if the
'Items' insert works, the likelihood is that the 'Pictures' inserts will
too.

How does this sound?

Thanks for any input.

Jim.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to