Re: Any One See where this is going wrong?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2010-04-30 at 20:43 -0400, 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');
> 
> 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') && 
> ($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
> 
> 
> 
> 
> 


Is it possible that this server doesn't like batch queries? Try
splitting them out into individual queries and seeing if that helps. If
that doesn't do the trick, print out the SQL query string to see if it's
what you expect. It might be working fine on the other server, but I've
seen enough strange things happen before to know that sometimes 'poo'
happens.

Thanks,
Ash
http://www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux