Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Angry Help with Functions/ Buggy Code

    I really cannot find the bug in this. The $imageid variable wont register with my function!
    PHP Code:
    <?php

        $dbhost 
    "localhost";
        
    $dbname "****";
        
    $dbuser "****";
        
    $dbpass "****";


            
    //Connection handle
            
    $db = @mysql_connect("$dbhost","$dbuser","$dbpass");
            
    mysql_select_db("$dbname") or die( "Unable to select database. Check your connection handle.");

            
    session_start();

    if(isset(
    $_POST["upload"])){

    //    $imageid = $_POST["ref"];
        
    $imageid "100";

    $thumb_size $_FILES['thumb']['size'];
    $large_size $_FILES['large']['size'];
    $upload_size $_FILES['upload']['size'];

    function 
    uploadImage($width,$height,$getfrom,$cat,$imageid) {

        
    $queryorder mysql_query("SELECT `order` FROM `images` WHERE ref ='".$imageid."' ORDER BY `order` DESC LIMIT 0,1");
        
    $resultorder mysql_num_rows($queryorder);if($resultorder == 0){ $neworder 1; }
        else {
            
    $orderimgs mysql_fetch_array($queryorder);
            
    $oldorder $orderimgs["order"];
            
    $neworder = ($oldorder 1);
        }
        
    $querysuffix mysql_query("SELECT `suffix` FROM `images` WHERE ref ='".$imageid."' ORDER BY `suffix` DESC LIMIT 0,1");
        
    $resultsuffix mysql_num_rows($querysuffix);if($resultsuffix == 0){ $newsuffix '_1'; }
        else {
            
    $suffiximgs mysql_fetch_array($querysuffix);
            
    $oldsuffix $suffiximgs["suffix"];
            
    $newsuffix = ($oldsuffix 1);
            
    $newsuffix '_'.$newsuffix;
        }

        
    $image_name "uploads/".$imageid.''.$newsuffix.".jpg";
        
    $max_large_width $width;
        
    $max_large_height $height;
        
    $large_userfile_name $_FILES[$getfrom]['name'];
        
    $large_userfile_tmp $_FILES[$getfrom]['tmp_name'];
        
    move_uploaded_file($large_userfile_tmp,$image_name);
        
    chmod ($image_name,octdec(644));
        list(
    $w1,$h1) = getimagesize($image_name);
        if(
    $w1 $h1){
            if(
    $w1 $max_large_width){
                
    $aspect_ratio $w1/$h1;
                
    $new_large_width $max_large_width;
                
    $new_large_height abs($new_large_width/$aspect_ratio);
                    
    $destimg=ImageCreateTrueColor($new_large_width,$new_large_height) or die('Problem In Creating image');
                    
    $srcimg=ImageCreateFromJPEG($image_name) or die('Problem In opening Source Image');
                    if(
    function_exists('imagecopyresampled'))
                    {
                        
    imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }else{
                        
    Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }
                    
    ImageJPEG($destimg,$image_name,100) or die('Problem In saving');
            }
        }
        if(
    $h1 $w1){
            if(
    $h1 $max_large_height){
                
    $aspect_ratio $h1/$w1;
                
    $new_large_height $max_large_height;
                
    $new_large_width abs($new_large_height/$aspect_ratio);
                    
    $destimg=ImageCreateTrueColor($new_large_width,$new_large_height) or die('Problem In Creating image');
                    
    $srcimg=ImageCreateFromJPEG($image_name) or die('Problem In opening Source Image');
                    if(
    function_exists('imagecopyresampled'))
                    {
                        
    imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }else{
                        
    Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }
                    
    ImageJPEG($destimg,$image_name,100) or die('Problem In saving');
            }
        }
        
    mysql_query("INSERT INTO `images` (`ref`,`order`,`suffix`,`cat`)VALUES('$imageid','$neworder','$newsuffix','$cat')");
        
    imagedestroy($destimg);

    echo 
    '<img src="http://www.caravansandtrailertents.co.uk/'.$image_name.'"><br/>'.$image_name.' '.$imageid.'<br/>';

    }

    //Large Images
     
    uploadImage('560','400','large','1',$imageid);
     
    uploadImage('70','55','large','2',$imageid);
    //Thumbnail Images
     
    uploadImage('150','120','thumb','3',$imageid);
     
    uploadImage('70','55','thumb','4',$imageid);

    }

    else {

    echo 
    '


    <form action="/imageupload.php" method="post" enctype="multipart/form-data">
    <table>
    <tr>
        <td>Thumbnail:</td>
        <td style="text-align:left"><input name="thumb" type="file" style="width:260px" value="" /></td>
    </tr>
    <tr>
        <td>Large Image:</td>
        <td style="text-align:left"><input name="large" type="file" style="width:260px" value="" /></td>
    </tr>
    </table>
    <input type="submit"  value="resize" name="upload">


    '
    ;

    }

    ?>
    Last edited by danielwarner; 12-24-2006 at 05:23 PM.
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Try this:

    PHP Code:
    $queryorder mysql_query("SELECT `order` FROM `images` WHERE ref ='".$imageid."' ORDER BY `order` DESC LIMIT 0,1"); 
    and

    PHP Code:
    $querysuffix mysql_query("SELECT `suffix` FROM `images` WHERE ref ='".$imageid."' ORDER BY `suffix` DESC LIMIT 0,1"); 
    Note the ". and ." around $imageid

    Dan

    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    Regular Coder meth's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Your problem lies with variable scope. It could also lie with $imageid being delineated with apostrophies. If the db table column datatype is numeric, then you need to pass $imageid as a numeric value, not a string.
    Last edited by meth; 12-23-2006 at 07:18 PM.
    I do Web Design, Brisbane based.
    More time spent in PHP/MySQL Web Development.
    And Search Engine Optimisation takes up the rest of it.

  • #4
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts
    I edited my code but it still doesnt work. the script tries to echo the variable and wont display anything...im sure this has something to do with the way it is passed into the function. Is the layout of my function correct or is there a reason it isnt being passed?
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  • #5
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Could you please tell us what error message you get (or exactly what output you get). Are error messages on? It should be possible to debug your script by e.g. adding some 'var_dump' statements selected places to see where things go wrong. (Much easier than looking at the entire script without running it).

    Are you sure $imageid isn't passed to the function??? Find out by putting a var_dump($imageid); in the first line of the function to display its value.

  • #6
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts
    This is the url with the code on it. >>http://www.caravansandtrailertents.co.uk/trialupload.php<< no error message is displayed and i do attempt to echo the variable name and image name. The name should come out to be uploads/100_1.jpg etc etc... but at the moment its just the ..._1 part of the file name that comes out. (which is a problem because the name links to the images id).

    The var_dump hasnt shown anything.

    I have read the tutorial on Variable scope, which i atchually found very interesting although irrelevent and i did atchually learn something from it which i didnt already know. I do believe i am passing the ID number into the function though (although this is the 3/ 4th time i have ever used a function before so it may be wrong!)

    Thanks for showing interest!!

    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  • #7
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    While I see the error when running your live version of the script, I tried to run your script on my own server, setting up a single table in the database too. But I couldn't reproduce the error. I got uploads/100_1.jpg. So I really have no clue what the problem could be?
    The var_dump hasnt shown anything.
    Can you then verify that you get dumped the value NULL? I believe that the var_dump should always outputs something... Did you try:
    PHP Code:
    function uploadImage($width,$height,$getfrom,$cat,$imageid) {
      
    var_dump($imageid);
      
    // the rest of the function

    This should definitely tell us whether $imageid is passed to the function or not.

  • #8
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts
    yup its in there...didnt show me anything though

    Can you show me a dump of the table you used please....its a long shot but that may have something to do with it i guess...
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  • #9
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,037
    Thanks
    2
    Thanked 316 Times in 308 Posts
    Adding the following line after your first opening <?php tag might give more information about what is going on (you might also need to turn on display_errors to receive any output) -
    PHP Code:
    error_reporting(E_ALL); 
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #10
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    The var_dump hasnt shown anything.
    var_dump() if actually called, always prints something.
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #11
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Ok thanks for the help everyone i have got the ID number to display now somehow? My Problem is now that the images that i try to resize all come out at a fixed size and with the same suffix although they should increment.

    The more uptodate code is posted below.

    Thanks for everyones help.

    PHP Code:
    <?php

        $dbhost 
    "localhost";
        
    $dbname "****";
        
    $dbuser "****";
        
    $dbpass "****";


            
    //Connection handle
            
    $db = @mysql_connect("$dbhost","$dbuser","$dbpass");
            
    mysql_select_db("$dbname") or die( "Unable to select database. Check your connection handle.");

    if(isset(
    $_POST["upload"])){

            
    $imageid $_POST["ref"];

    $thumb_size $_FILES['thumb']['size'];
    $large_size $_FILES['large']['size'];
    $upload_size $_FILES['upload']['size'];

    function 
    uploadImage($width,$height,$getfrom,$cat,$imageid) {

        
    $queryorder mysql_query("SELECT `order` FROM `images` WHERE ref ='".$imageid."' ORDER BY `order` DESC LIMIT 0,1");
        
    $resultorder mysql_num_rows($queryorder);if($resultorder == 0){ $neworder 1; }
        else {
            
    $orderimgs mysql_fetch_array($queryorder);
            
    $oldorder $orderimgs["order"];
            
    $neworder = ($oldorder 1);
        }
        
    $querysuffix mysql_query("SELECT `suffix` FROM `images` WHERE ref ='".$imageid."' ORDER BY `suffix` DESC LIMIT 0,1");
        
    $resultsuffix mysql_num_rows($querysuffix);if($resultsuffix == 0){ $newsuffix '_1'; }
        else {
            
    $suffiximgs mysql_fetch_array($querysuffix);
            
    $oldsuffix $suffiximgs["suffix"];
            
    $newsuffix = ($oldsuffix 1);
            
    $newsuffix '_'.$newsuffix;
        }

        
    $image_name "uploads/".$imageid.''.$newsuffix.".jpg";
        
    $max_large_width $width;
        
    $max_large_height $height;
        
    $large_userfile_name $_FILES[$getfrom]['name'];
        
    $large_userfile_tmp $_FILES[$getfrom]['tmp_name'];
        
    move_uploaded_file($large_userfile_tmp,$image_name);
        
    chmod ($image_name,octdec(644));
        list(
    $w1,$h1) = getimagesize($image_name);
        if(
    $w1 $h1){
            if(
    $w1 $max_large_width){
                
    $aspect_ratio $w1/$h1;
                
    $new_large_width $max_large_width;
                
    $new_large_height abs($new_large_width/$aspect_ratio);
                    
    $destimg=ImageCreateTrueColor($new_large_width,$new_large_height) or die('Problem In Creating image');
                    
    $srcimg=ImageCreateFromJPEG($image_name) or die('Problem In opening Source Image');
                    if(
    function_exists('imagecopyresampled'))
                    {
                        
    imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }else{
                        
    Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }
                    
    ImageJPEG($destimg,$image_name,100) or die('Problem In saving');
            }
        }
        if(
    $h1 $w1){
            if(
    $h1 $max_large_height){
                
    $aspect_ratio $h1/$w1;
                
    $new_large_height $max_large_height;
                
    $new_large_width abs($new_large_height/$aspect_ratio);
                    
    $destimg=ImageCreateTrueColor($new_large_width,$new_large_height) or die('Problem In Creating image');
                    
    $srcimg=ImageCreateFromJPEG($image_name) or die('Problem In opening Source Image');
                    if(
    function_exists('imagecopyresampled'))
                    {
                        
    imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }else{
                        
    Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }
                    
    ImageJPEG($destimg,$image_name,100) or die('Problem In saving');
            }
        }
        
    mysql_query("INSERT INTO `images` (`ref`,`order`,`suffix`,`cat`)VALUES('$imageid','$neworder','$newsuffix','$cat')");
        
    imagedestroy($destimg);

    echo 
    '<img src="http://www.caravansandtrailertents.co.uk/'.$image_name.'"><br/>'.$image_name.' '.$imageid.'<br/>';

    }

    //Large Images
    if($large_size 0) {
     
    uploadImage('560','400','large','1',$imageid);
     
    uploadImage('70','55','large','2',$imageid);
    }
    //Thumbnail Images
    if($thumb_size 0) {
     
    uploadImage('150','120','thumb','3',$imageid);
     
    uploadImage('70','55','thumb','4',$imageid);
    }

    }

    else {

    echo 
    '


    <form action="/imageupload.php" method="post" enctype="multipart/form-data">
    <table>
    <tr>
        <td>Thumbnail:</td>
        <td style="text-align:left"><input name="thumb" type="file" style="width:260px" value="" /></td>
    </tr>
    <tr>
        <td>Large Image:</td>
        <td style="text-align:left"><input name="large" type="file" style="width:260px" value="" /></td>
    </tr>
    </table>
    <input type="hidden" value="100" name="ref"/>
    <input type="submit"  value="resize" name="upload"/>


    '
    ;

    }

    ?>
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  • #12
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts
    * Picks up computer and throws it out the window *

    Im really sorry for wasting your time. The problem was that the file i was trying to make work was called trialupload.php. This is a cut and paste job of a larger form which made it easier to refresh the image upload system and avoid the sequrity of the larger form. The larger form was called imageupload.php and if you look in the code i posted called trialupload.php the form still pointed to the old file called imageupload.php. This means all the work i was trying to do to fix it wasnt athchually being tested but was sitting in a different file.

    I think i can fix it on my own now its just that before i was very unframiliar with the irregular result php was showing me!

    Im very sorry for wasting your time and im very greatful that you spent the time to help me fix my script!
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  • #13
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by danielwarner View Post
    I think i can fix it on my own now its just that before i was very unframiliar with the irregular result php was showing me!
    Won't it be difficult without the computer?
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.

  • #14
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts
    * Picks up computer and plugs it back in *


    ...sorry me again.

    Got abit carried away before when i got it to work and now i have got another bug although this one i cant understand at all.

    What happened is i managed to get the images to resize, upload to my server, upload to my database, rename them all, fixed a few more bugs along the way untill i finally finished and it worked perfectly. Then it struck me. Because i have 2 of the same image sometimes that are just sized differently i needed a database column to show a link between the two image files. I made this and it worked, but then the images decided not to resize themselves to their correct defined size and all come out small. Not only this i have found that although the images load to the database correctly the suffix seems to be fixed at _10. I dont know whats causing this and i suspect this is the reason all 5 images havnt been uploaded to my server but only 1 of them has (being 72_10.jpg)

    Test the code for yourself >>http://www.caravansandtrailertents.co.uk/trialupload.php<<

    Thanks for the help



    This is the new code
    PHP Code:
    <?php
    error_reporting
    (E_ALL);

        
    $dbhost "72.41.255.202";
        
    $dbname "danielw_catt";
        
    $dbuser "danielw_admin";
        
    $dbpass "jomooss9115";


            
    //Connection handle
            
    $db = @mysql_connect("$dbhost","$dbuser","$dbpass");
            
    mysql_select_db("$dbname") or die( "Unable to select database. Check your connection handle.");

            
    session_start();

    if(isset(
    $_POST["init"])){

        
    $imageid $_POST["ref"];

    $thumb_size $_FILES['thumb']['size'];
    $large_size $_FILES['large']['size'];
    $upload_size $_FILES['upload']['size'];

    function 
    uploadImage($getfrom,$cat,$enabled,$imageid) {

        
    $queryorder mysql_query("SELECT `order` FROM `images` WHERE ref ='$imageid' ORDER BY `order` DESC LIMIT 0,1");
        
    $resultorder mysql_num_rows($queryorder);if($resultorder == 0){ $neworder 1; }
        else {
            
    $orderimgs mysql_fetch_array($queryorder);
            
    $oldorder $orderimgs["order"];
            
    $neworder = ($oldorder 1);
        }
        
    $querysuffix mysql_query("SELECT `suffix` FROM `images` WHERE ref ='$imageid' ORDER BY `suffix` DESC LIMIT 0,1");
        
    $resultsuffix mysql_num_rows($querysuffix);
        if(
    $resultsuffix <= 1){
            
    $suffiximgs mysql_fetch_array($querysuffix);
            
    $oldsuffix $suffiximgs["suffix"];
            
    $newoldsuffix str_replace("_","",$oldsuffix);
            
    $newsuffix = ($newoldsuffix 1);
            
    $newsuffix '_'.$newsuffix;
        }else{
    $newsuffix '_1';}
        
    $querylink mysql_query("SELECT `link` FROM `images` WHERE ref ='$imageid' ORDER BY `link` DESC LIMIT 0,1");
        
    $resultlink mysql_num_rows($querylink);
        if(
    $resultlink <= 1){
            
    $linkimgs mysql_fetch_array($querylink);
            
    $oldlink $linkimgs["link"];
            
    $newlink = ($oldlink 1);
        }else{
    $newlink '1';}
        if(
    $cat 1){ $newlink = ($newlink 1); }

            if(
    $cat == 1){ //Large Image
                
    $max_large_width "560";
                
    $max_large_height "400";
            }
            if(
    $cat == 2){ //Thumbnail Image
                
    $max_large_width "150";
                
    $max_large_height "120";
            }
            if(
    $cat == 3){ //Small Image
                
    $max_large_width "70";
                
    $max_large_height "55";
            }

    if(
    $cat 1){
      
    $image_name "uploads/".$imageid.''.$oldsuffix.".jpg";
      
    $image_name2 "uploads/".$imageid.''.$newsuffix.".jpg";
    }
    if(
    $cat == 1){
        
    $image_name "uploads/".$imageid.''.$newsuffix.".jpg";
        
    $image_name2 $image_name;
        
    $large_userfile_name $_FILES[$getfrom]['name'];
        
    $large_userfile_tmp $_FILES[$getfrom]['tmp_name'];
        
    move_uploaded_file($large_userfile_tmp,$image_name);
        
    chmod ($image_name,octdec(644));
    }
        list(
    $w1,$h1) = getimagesize($image_name);
        if(
    $w1 $h1){
            if(
    $w1 $max_large_width){
                
    $aspect_ratio $w1/$h1;
                
    $new_large_width $max_large_width;
                
    $new_large_height abs($new_large_width/$aspect_ratio);
                    
    $destimg=ImageCreateTrueColor($new_large_width,$new_large_height) or die('Problem In Creating image');
                    
    $srcimg=ImageCreateFromJPEG($image_name) or die('Problem In opening Source Image');
                    if(
    function_exists('imagecopyresampled'))
                    {
                        
    imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }else{
                        
    Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }
                    
    ImageJPEG($destimg,$image_name2,100) or die('Problem In saving');
            }
        }
        if(
    $h1 $w1){
            if(
    $h1 $max_large_height){
                
    $aspect_ratio $h1/$w1;
                
    $new_large_height $max_large_height;
                
    $new_large_width abs($new_large_height/$aspect_ratio);
                    
    $destimg=ImageCreateTrueColor($new_large_width,$new_large_height) or die('Problem In Creating image');
                    
    $srcimg=ImageCreateFromJPEG($image_name) or die('Problem In opening Source Image');
                    if(
    function_exists('imagecopyresampled'))
                    {
                        
    imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }else{
                        
    Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_large_width,$new_large_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
                    }
                    
    ImageJPEG($destimg,$image_name2,100) or die('Problem In saving');
            }
        }
        
    mysql_query("INSERT INTO `images` (`ref`,`order`,`suffix`,`cat`,`enabled`,`link`)VALUES('$imageid','$neworder','$newsuffix','$cat','$enabled','$newlink')");
        
    imagedestroy($destimg);

    echo 
    '<img src="http://www.caravansandtrailertents.co.uk/'.$image_name2.'"><br/>'.$image_name2.'<br/>';

    }

    if(
    $large_size 0){
      
    uploadImage('large','1','1',$imageid);
    }
    if(
    $thumb_size 0){
      
    uploadImage('thumb','1','0',$imageid);
      
    uploadImage('thumb','2','1',$imageid);
    }
    if(
    $upload_size 0){
      
    uploadImage('upload','1','1',$imageid);
      
    uploadImage('upload','3','1',$imageid);
    }

    }

    else {

    echo 
    '


    <form action="/trialupload.php" method="post" enctype="multipart/form-data">
    <table>
    <tr>
        <td>Thumbnail:</td>
        <td style="text-align:left"><input name="thumb" type="file" style="width:260px" value="" /></td>
    </tr>
    <tr>
        <td>Large Image:</td>
        <td style="text-align:left"><input name="large" type="file" style="width:260px" value="" /></td>
    </tr>
    <tr>
        <td>Upload Image:</td>
        <td style="text-align:left"><input name="upload" type="file" style="width:260px" value="" /></td>
    </tr>
    </table>
    <input type="hidden" name="ref" value="72"/>
    <input type="submit"  value="resize" name="init"/>


    '
    ;

    }

    ?>
    Infact, after running a few tests, the images all resize to the smallest (or maybe just last) image size that has been defined. Because the Suffix isnt changing this may be the reason why all the images are being shown as smaller. as the page is attempting to load the last image made 5 times when being echo'd.
    Last edited by danielwarner; 12-26-2006 at 02:28 AM.
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •