Please help us!
We are placing a one form page for client updating of their database. We want to be able to have them fill in a form, as well as select a picture location, and have the information and image entered properly into the database. We have made this application work with two separate actions (complete the initial information first, then add a picture second). We have also combined the two into one form, although our client has to specify the name of the picture itself for database reference.
We now would like to use the Last Insert Id command to automatically name the image so the client doesn’t have to worry about unique names and redundant renaming after image selection. We were originally trying to auto increment this, but believe that the last insert id is the right way to do it.
Following is our script, although the definition of file name was originally written for auto increment use. Please advise us as to what corrections or additions we need to make, as well as WHERE we should make them. We are very new to this.
Thank you for your help.
<?
if ($submit) {
$connection = mysql_connect("localhost", "", "")
or die ("Couldn't connect to server.");
$db = mysql_select_db("client", $connection)
or die ("Couldn't select database.");
$filename = ("image" . $id . ".jpg");
copy($image, "/path/pics/$filename");
$filesize=filesize($image);
$filetype=filetype($image);
mysql_query("INSERT INTO inventory VALUES
('$id', '$trailertype', '$info', '$filename', '$filesize', '$filetype', '$description', '$pulltype', '$size', '$weight', '$price')") or die (mysql_error());
echo "