I have a image upload script that loops and uploads and resizes images great. During the script it assigns names to the images with this bit of code.
$imgfile_name = $_FILES['userfile']['name'][$key];
srand((double)microtime()*1000000);
$unique_str = md5(rand(0,9999999));
$p = strrpos($imgfile_name, "." );
$old_name = substr($imgfile_name , 0 , $p ) . $unique_str . substr($imgfile_name , $p , ( strlen($imgfile_name ) - $p ) );
$new_name = str_replace(" ","_",$old_name);
$db_names[] = $new_name;
I can the write the values of $db_names [0], $db_names[1] etc to the database.
What I am having an issue with is when the user wants to pull a particular record from the datbase and change/replace a picture or two with new ones, i only need to write the new image names to that particular field in the table (pic1,pic3,etc.).
I use this but it doesnt want to update the correct fields if it updates at all unless all six images are replaced/changed.
//db_names 1
if(!empty($_FILES['userfile']['name'][0]))
{
$query = "UPDATE farm_hunting_properties SET pic1 = '$db_names[0]' WHERE id = '$id'";
$result mysql_db_query($DBName, $query, $Link) or die(mysql_error());
print "Picture 1 Changed<br><br>";
}
//end db_names 1
Thanks for the help