adam291086 Posted October 1, 2007 Share Posted October 1, 2007 hello, i have an online gallery working. But when two photos are uploaded i get the error message. One photo is uploaded but the other isn't. Can anyone see why? Still here!Images successfully converted and stored! Click here to continue.Still here! Fatal error: Cannot redeclare insert_location() (previously declared in /homepages/12/d214897219/htdocs/adam/create_thumbnails.php:52) in /homepages/12/d214897219/htdocs/adam/create_thumbnails.php on line 52 <?php include("GallerySizer.php"); include("config.php"); DEFINE("IMAGE_FULL", '../adam/photos/'); //database connect $db_server ="db1125.oneandone.co.uk"; $db_user = "dbo218351273"; $db_pass = "adawman291086"; $db_name = "db218351273"; $con = mysql_connect("$db_server","$db_user","$db_pass"); // Album cover $cover = $_FILES['image']['name'][$_POST['album_cover']]; if (!$_REQUEST['process']){ echo("Error! No images chosen for processing. <br />"); echo("Click <a href='index.php'>here</a> to start processing your images."); die(); } elseif (!$_POST['album_id']){ echo("No album selected. Please <a href=\"\">choose an album</a> to upload images to."); die(); } else { for($i = 0; $i < count($_FILES['image']['tmp_name']); $i++){ $fileName = $_FILES['image']['name'][$i]; copy($_FILES['image']['tmp_name'][$i], IMAGE_FULL . $fileName); $thumb = new GallerySizer(); if($thumb->getLocation($_FILES['image']['name'][$i])){ if($thumb->loadImage()){ echo("Still here!"); if($thumb->getSize()){ if($thumb->setThumbnail()){ if($thumb->copyThumbImage()){ if($thumb->resizeImage()){ $thumb->copyResizedImage(); } } } } } else { echo("Invalid image/file has been uploaded. Please upload a supported file-type (JPEG/PNG)"); unlink(IMAGE_FULL . $fileName); die(); } //insert image function insert_location($thumb_obj) { $image_location = $thumb_obj->getImageLocation(); $thumb_location = $thumb_obj->getThumbLocation(); // If image matches cover selection, update album cover if($cover == $_FILES['image']['name'][$i]){ $sql = "UPDATE albums SET album_cover = '" . $thumb_location . "' WHERE album_id = " . $_POST['album_id']; $result = @mysql_query($sql) or die("Error inserting records: " . mysql_error()); } mysql_select_db("db218351273", $con); $sql = ("INSERT INTO photos (photo_id, photo_title, photo_desc, photo_date, photo_location, thumbnail_location,album_id) VALUES('0', '$_POST[photo_title]', '$_POST[photo_desc]', 'NOW()', '$image_location', '$thumb_location', '$_POST[album_id]')"); $result = mysql_query($sql) or die("Error inserting record(s) into the database: " . mysql_error()); if ($result){ echo("Images successfully converted and stored! <br />Click <a href='index.html'>here</a> to continue."); } } insert_location($thumb); } } } ?> sorry about the code, im having to use Notpad as i am at work Quote Link to comment https://forums.phpfreaks.com/topic/71376-solved-fatal-error-cannot-redeclare-insert_location/ Share on other sites More sharing options...
d.shankar Posted October 1, 2007 Share Posted October 1, 2007 Sorry for double post ! Quote Link to comment https://forums.phpfreaks.com/topic/71376-solved-fatal-error-cannot-redeclare-insert_location/#findComment-359174 Share on other sites More sharing options...
d.shankar Posted October 1, 2007 Share Posted October 1, 2007 Try giving the absolute path DEFINE("IMAGE_FULL", '../adam/photos/'); Quote Link to comment https://forums.phpfreaks.com/topic/71376-solved-fatal-error-cannot-redeclare-insert_location/#findComment-359175 Share on other sites More sharing options...
adam291086 Posted October 1, 2007 Author Share Posted October 1, 2007 Sorry i am new to this, how do you mean the full path? Quote Link to comment https://forums.phpfreaks.com/topic/71376-solved-fatal-error-cannot-redeclare-insert_location/#findComment-359177 Share on other sites More sharing options...
adam291086 Posted October 1, 2007 Author Share Posted October 1, 2007 Worked out what you ment. I still get the same error. Quote Link to comment https://forums.phpfreaks.com/topic/71376-solved-fatal-error-cannot-redeclare-insert_location/#findComment-359189 Share on other sites More sharing options...
d.shankar Posted October 1, 2007 Share Posted October 1, 2007 Try now <?php include("GallerySizer.php"); include("config.php"); DEFINE("IMAGE_FULL", '../adam/photos/'); //database connect $db_server ="db1125.oneandone.co.uk"; $db_user = "dbo218351273"; $db_pass = "adawman291086"; $db_name = "db218351273"; $con = mysql_connect("$db_server","$db_user","$db_pass"); // Album cover $cover = $_FILES['image']['name'][$_POST['album_cover']]; if (!$_REQUEST['process']){ echo("Error! No images chosen for processing. <br />"); echo("Click <a href='index.php'>here</a> to start processing your images."); die(); } elseif (!$_POST['album_id']){ echo("No album selected. Please <a href=\"\">choose an album</a> to upload images to."); die(); } else { for($i = 0; $i < count($_FILES['image']['tmp_name']); $i++){ $fileName = $_FILES['image']['name'][$i]; copy($_FILES['image']['tmp_name'][$i], IMAGE_FULL . $fileName); $thumb = new GallerySizer(); if($thumb->getLocation($_FILES['image']['name'][$i])){ if($thumb->loadImage()){ echo("Still here!"); if($thumb->getSize()){ if($thumb->setThumbnail()){ if($thumb->copyThumbImage()){ if($thumb->resizeImage()){ $thumb->copyResizedImage(); } } } } } else { echo("Invalid image/file has been uploaded. Please upload a supported file-type (JPEG/PNG)"); unlink(IMAGE_FULL . $fileName); die(); } //insert image insert_location($thumb); } } } function insert_location($thumb_obj) { $image_location = $thumb_obj->getImageLocation(); $thumb_location = $thumb_obj->getThumbLocation(); // If image matches cover selection, update album cover if($cover == $_FILES['image']['name'][$i]){ $sql = "UPDATE albums SET album_cover = '" . $thumb_location . "' WHERE album_id = " . $_POST['album_id']; $result = @mysql_query($sql) or die("Error inserting records: " . mysql_error()); } mysql_select_db("db218351273", $con); $sql = ("INSERT INTO photos (photo_id, photo_title, photo_desc, photo_date, photo_location, thumbnail_location,album_id) VALUES('0', '$_POST[photo_title]', '$_POST[photo_desc]', 'NOW()', '$image_location', '$thumb_location', '$_POST[album_id]')"); $result = mysql_query($sql) or die("Error inserting record(s) into the database: " . mysql_error()); if ($result){ echo("Images successfully converted and stored! <br />Click <a href='index.html'>here</a> to continue."); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/71376-solved-fatal-error-cannot-redeclare-insert_location/#findComment-359194 Share on other sites More sharing options...
adam291086 Posted October 1, 2007 Author Share Posted October 1, 2007 You guys are fantastic. I don't know how you do it. I can understand what goes on in my code, but anyone elses and i am stuck THANKS Quote Link to comment https://forums.phpfreaks.com/topic/71376-solved-fatal-error-cannot-redeclare-insert_location/#findComment-359198 Share on other sites More sharing options...
d.shankar Posted October 1, 2007 Share Posted October 1, 2007 Did that code solve your problem or not adam ? Quote Link to comment https://forums.phpfreaks.com/topic/71376-solved-fatal-error-cannot-redeclare-insert_location/#findComment-359200 Share on other sites More sharing options...
adam291086 Posted October 1, 2007 Author Share Posted October 1, 2007 It sure did Quote Link to comment https://forums.phpfreaks.com/topic/71376-solved-fatal-error-cannot-redeclare-insert_location/#findComment-359207 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.