Jim Thanks for your reponse. With the variable defined. it is supposed to reduce the size of the image before upload. Thanks again. Gary "Jim Lucas" <lists@xxxxxxxxx> wrote in message news:4BDC311B.4060100@xxxxxxxxxxxx > Gary wrote: >> I have this duplicate code on another site and it works fine. The image >> is uploaded to the images folder, the information is not submitted to the >> database. I get the error >> >> Some Error Occured While Inserting Records >> >> This is only on a local machine so I have not yet included and safegaurds >> like stripslashes or my_real_escape_string. >> >> Thanks for your help >> >> Gary >> >> <?php >> if (isset($_POST['submit'])) { >> $manufacturer=($_POST['manufacturer']); >> $type=($_POST['type']); >> $model=($_POST['model']); >> $caliber=($_POST['caliber']); >> $condition=($_POST['condition']); >> $price=($_POST['price']); >> $description=($_POST['description']); >> $image_file_name=($_POST['image_file_name']); >> $image_file=($_FILES['image_file']); >> $available=($_POST['available']); >> >> $image_file = $_FILES['image_file']['name']; >> $image_type = $_FILES['image_file']['type']; >> $image_size = $_FILES['image_file']['size']; >> >> include ('includes/connect_local.inc.php'); >> > > Is the following line suppose to be working with a constant or the > variable that you defined/extracted just above here? > >> if(image_size >3000000) { >> >> class ImgResizer { >> private $originalFile = 'image_file'; >> public function __construct($originalFile = 'image_file') { >> $this -> originalFile = $originalFile; >> } >> public function resize($newWidth, $targetFile) { >> if (empty($newWidth) || empty($targetFile)) { >> return false; >> } >> $src = imagecreatefromjpeg($this -> originalFile); >> list($width, $height) = getimagesize($this -> originalFile); >> $newHeight = ($height / $width) * $newWidth; >> $tmp = imagecreatetruecolor($newWidth, $newHeight); >> imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, >> $width, $height); >> if (file_exists($targetFile)) { >> unlink($targetFile); >> } >> imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between >> 0 - 100 for output image quality with 100 being the most luxurious >> } >> } >> } >> if (!empty($type) && !empty($image_file)) { >> if (($image_type == 'image/gif') || ($image_type == 'image/jpeg') >> || ($image_type == 'image/pjpeg') || ($image_type == 'image/png') && > > By the use of a variable below, I'm guessing it was suppose to be a > variable. > >> ($image_size <3000000)) { >> if ($_FILES['image_file']['error'] == 0) { >> // Move the file to the target upload folder >> $target = 'images/' . $image_file; >> if (move_uploaded_file($_FILES['image_file']['tmp_name'], >> $target)){ >> $batchconnection; >> >> $sqlStatements = "INSERT INTO guns( id,manufacturer, type, model, >> caliber, condition, price, description, image_file_name,submitted >> ,available) VALUES ('','$manufacturer', '$type', '$model', '$caliber', >> '$condition', '$price', '$description','$image_file_name', ' ', >> '$available'); >> >> INSERT INTO images (id, image_file) VALUES('','$image_file')"; >> >> $sqlResult = $batchconnection->multi_query($sqlStatements); >> if($sqlResult == true) { >> echo "Successfully Inserted Records"; >> } else { >> echo "Some Error Occured While Inserting Records"; >> } >> >> >> >> } >> >> } >> } >> } >> mysqli_close($batchconnection); >> } >> ?> __________ Information from ESET Smart Security, version of virus >> signature database 5076 (20100430) __________ >> >> The message was checked by ESET Smart Security. >> >> http://www.eset.com >> >> >> >> >> > > > -- > Jim Lucas > > A: Maybe because some people are too annoyed by top-posting. > Q: Why do I not get an answer to my question(s)? > A: Because it messes up the order in which people normally read text. > Q: Why is top-posting such a bad thing? > > __________ Information from ESET Smart Security, version of virus > signature database 5077 (20100501) __________ > > The message was checked by ESET Smart Security. > > http://www.eset.com > > > __________ Information from ESET Smart Security, version of virus signature database 5077 (20100501) __________ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php