php gallery script picture placement problem
Posted: Sun Mar 14, 2010 9:45 pm
Hello I just took over the maintenance of a website and I am having trouble with a script that was made for the gallery section.
The pictures are added from website.com/crm/websitegallery page where there is a function to add pictures. This script creates a thumbnail and randomly renames the pictures and adds them both to the "gallery" table in phpmyadmin.
my problem is when adding a new picture to a specific gallery it will not place the picture after the end of the last picture in that gallery but rather randomly for some reason.
this is the code i have right now.
}
if ($_REQUEST['upload'] == 1) {
$i = 0;
foreach ($TheFile as $uploadKey => $uploadImage) {
if ($uploadImage != "") {
$uploadhash = basename($uploadImage);
$uploadhashext = explode(".", $uploadhash);
$uploadhash = $uploadhash . mt_rand();
$uploadhash = md5($uploadhash);
$uploaddir = "/sites/yuma3/dougdolson/home/public_html/images/gallery/";
$uploadfile[$i] = $uploaddir . $uploadhash . "." . $uploadhashext[1];
$savefile[$i] = $uploadhash . "." . $uploadhashext[1];
$i++;
}
}
$ii = 0;
while ($ii < $i) {
move_uploaded_file($TempFile[$ii], $uploadfile[$ii]);
$savethumb = "tn_" . $savefile[$ii];
$imageQuery = "INSERT INTO Gallery (`GalleryID`,`Thumbnail`,`Fullsize`,`Title`,`Description`,`GroupID`) VALUES (NULL, '$savethumb', '$savefile[$ii]', '', '', '$groupId')";
$SaveImage=$mysqli->prepare($imageQuery);
#$SaveImage=$mysqli->prepare("INSERT INTO Gallery (`GalleryID`,`Thumbnail`,`Fullsize`,`GroupID`) VALUES (NULL, ?, ?, ?)");
#$SaveImage->bind_param("sss", $savethumb, $savefile[$ii], $groupId);
$SaveImage->execute();
$SaveImage->close();
$imageToResize = $uploaddir . $savefile[$ii];
createthumb("$imageToResize","$uploaddir$savethumb",80,60);
resizeimage($uploadfile[$ii]);
$ii++;
not sure if this is enough for anyone to get a good idea. This is about the second time I am working with php
Thank you for all your help
The pictures are added from website.com/crm/websitegallery page where there is a function to add pictures. This script creates a thumbnail and randomly renames the pictures and adds them both to the "gallery" table in phpmyadmin.
my problem is when adding a new picture to a specific gallery it will not place the picture after the end of the last picture in that gallery but rather randomly for some reason.
this is the code i have right now.
}
if ($_REQUEST['upload'] == 1) {
$i = 0;
foreach ($TheFile as $uploadKey => $uploadImage) {
if ($uploadImage != "") {
$uploadhash = basename($uploadImage);
$uploadhashext = explode(".", $uploadhash);
$uploadhash = $uploadhash . mt_rand();
$uploadhash = md5($uploadhash);
$uploaddir = "/sites/yuma3/dougdolson/home/public_html/images/gallery/";
$uploadfile[$i] = $uploaddir . $uploadhash . "." . $uploadhashext[1];
$savefile[$i] = $uploadhash . "." . $uploadhashext[1];
$i++;
}
}
$ii = 0;
while ($ii < $i) {
move_uploaded_file($TempFile[$ii], $uploadfile[$ii]);
$savethumb = "tn_" . $savefile[$ii];
$imageQuery = "INSERT INTO Gallery (`GalleryID`,`Thumbnail`,`Fullsize`,`Title`,`Description`,`GroupID`) VALUES (NULL, '$savethumb', '$savefile[$ii]', '', '', '$groupId')";
$SaveImage=$mysqli->prepare($imageQuery);
#$SaveImage=$mysqli->prepare("INSERT INTO Gallery (`GalleryID`,`Thumbnail`,`Fullsize`,`GroupID`) VALUES (NULL, ?, ?, ?)");
#$SaveImage->bind_param("sss", $savethumb, $savefile[$ii], $groupId);
$SaveImage->execute();
$SaveImage->close();
$imageToResize = $uploaddir . $savefile[$ii];
createthumb("$imageToResize","$uploaddir$savethumb",80,60);
resizeimage($uploadfile[$ii]);
$ii++;
not sure if this is enough for anyone to get a good idea. This is about the second time I am working with php
Thank you for all your help