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


if (isset($_POST['submit']))  {

$image_file = $_FILES['image_file']['name'];
$image_type = $_FILES['image_file']['type'];
$image_size = $_FILES['image_file']['size'];

include ('includes/');

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)) {
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)){

$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";



__________ Information from ESET Smart Security, version of virus signature 
database 5076 (20100430) __________

The message was checked by ESET Smart Security.

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?

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to