SitePoint Sponsor

User Tag List

Page 11 of 31 FirstFirst ... 78910111213141521 ... LastLast
Results 251 to 275 of 767
  1. #251
    SitePoint Enthusiast drewf's Avatar
    Join Date
    Mar 2002
    Location
    Calgary, AB
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In my opinion, without actually looking at your folder structure or your code in your pages, these errors do seem to be path related. The code is complaining that your photos directory is not in the path the code expects to access the photos themselves. Does your file directory structure look like or similar to this? Since I am not going to post an image I will try to get the point across with a textual description (<folder> means it would be a file folder in windows and <file> means PHP file named accordingly):

    <Folder>photos
    <file>config.inc.php
    <file>design.inc.php
    <file>preupload.php
    <file>upload.php
    <file>viewgallery.php
    etc...

    Your PHP files are NOT in the actual photos directory are they? The photos directory is a folder inside the folder containing the PHP files.

    Your error:
    Quote Originally Posted by jppp
    Warning: Division by zero in c:\ncdtree\my documents\php\example scripts\photos\upload.php on line 6

    tells me that this is the case...your PHP files are INSIDE the photos folder...the code will not be able to find the photos!!!! Hence your errors!

    Also check the config.inc.php page and make sure there is this line where the $images variable is located at the bottom of that page:
    $images_dir = "photos";

    Hopefully this puts you back on the right track. When learning php its easy to fall off track, a simple config error or spelling mistake is all you need to get unexpected results. Try to download my code archive I posted a ways back. It incorporates more advanced admin features and a secure login area for the admin, BUT you can compare your code to this code and since I know it works if implemented correctly, you can maybe get insight into where your's is going wrong...just a thought.

    Bye for now.
    Drew

    "The town where I grew up has a zip code of E-I-E-I-O."

  2. #252
    SitePoint Enthusiast drewf's Avatar
    Join Date
    Mar 2002
    Location
    Calgary, AB
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try Kevin Yank's famous tutorial on How To Build A Database Driven Website Using PHP and MySQL.

    http://www.sitepoint.com/article/php...1-installation (part1)

    http://www.sitepoint.com/article/getting-started-mysql (part2)

    http://www.sitepoint.com/article/mys...ng-started-php (part 3)

    http://www.sitepoint.com/article/pub...mysql-data-web (part 4)

    It's where I started with all this PHP business in the first place. Seriously, in 4 well written chapters you will know pretty much all you need to know to get your PDF archive up and running. It will not make your PDF's for you but will definitely walk you through how to make the links to such files derived from the database. After reading these 4 chapters I bought his book in revision 2 on the same subject. It might prevoke you to do the same. There are a lot of PDF specific tutorials out there that will show you how to get PHP to make them from scratch too should you want to get super fancy.



    Quote Originally Posted by sonomatek
    I think this is a great tutorial. I've used it a couple times now and have had no trouble making it fit in with my own style rules and code.

    I'm wondering if anyone knows of a similar tutorial that will do the same thing for an archive of PDF (or other formats) documents? I would like to use something similar to the photo gallery to create this archive, but instead of creating thumbnails, I want to create links out of the filenames so that people can download the files.

    If you can point me towards a good tutorial, I'd appreciate it.

    Thanks in advance!
    Drew

    "The town where I grew up has a zip code of E-I-E-I-O."

  3. #253
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    714
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot for your response. I am just reading through your thread and looking at my code to see how I can correct my code. I will let you know soon. Thanks once again. When the going gets tough and I get depressed, replies like these encourage me not to give up.

  4. #254
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Singapore
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help in upload.php...

    Hi,
    I've read thru all the threads but couldn't find an ans to this error:

    Notice: Undefined offset: 5 in c:\inetpub\wwwroot\videosig\photogallery\upload.php on line 35

    I really nd some help on this.. thank you!

  5. #255
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    714
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is the case...your PHP files are INSIDE the photos folder...the code will not be able to find the photos!!!! Hence your errors!
    You were so right. All my PHP files were inside the photos folder. Now I have corrected that. All my php files are inside a folder called photogallery. It also contains a folder called photos which contains the photographs which I want to upload.

    Now, when I go to try to upload my photographs, I get the following single error which I got last time too.

    Fatal error: Call to undefined function: imagecreatefromjpeg() in c:\ncdtree\my documents\php\example scripts\photogallery\upload.php on line 78
    PHP Code:
     
    // Build Thumbnail with GD 1.x.x, you can use the other described methods too
        
    $function_suffix $gd_function_suffix[$filetype]; // Line 78
        
    $function_to_read "ImageCreateFrom".$function_suffix;
        
    $function_to_write "Image".$function_suffix

    Also check the config.inc.php page and make sure there is this line where the $images variable is located at the bottom of that page:
    $images_dir = "photos";
    Well, I have downloaded the all my codes from the code archive, so there is no problem on that front.

    By the way, do I need to download GD? I thought that it was included as one of the functions of PHP. That alone should not be the reason for my fatal error, or is it?

  6. #256
    SitePoint Enthusiast drewf's Avatar
    Join Date
    Mar 2002
    Location
    Calgary, AB
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glad to have helped in that situation! You are bang on in questioning your version of the GD graphics library. There are two versions of the GD library, one version 1.x.x and the other 2.x.x. You really want version 2.x.x especially in this case as I strongly believe that you have it installed on your testing server. It may or may not be configured right and that is important to find out. Then again you may not have any version installed and we need to find this out. Version 2.x.x comes already bundled with the relatively latest version of PHP (I am personally using 4.3.9 and not 5...but you could use 5 too). Anyhow to test this you should create a simple php file named php_info.php and inside this copy and paste this code, you can remove the comments:

    PHP Code:
    <?php
    // PHP info will give you a wealth of information on your server's PHP setup
    // Migrate down (a fairly long way in the page) to a section heading named GD
    // It will tell you what version you are using, mine is 2.28.
     
    phpinfo();
    ?>
    Anyhow this will tell you which version of the code in Mayank's tutorial to use. Its extrememly important that you use the right set of GD specific functions in your PHP code or else you will get errors. See this is what I am thinking, you are using GD specific code for version 1.X.X in your code (as displayed with your thread) and in reality you have version 2.X.X of the GD library installed on your server. This is most likely causing you your errors. You should change out the section pertaining to GD 1.X.X and supliment it with the code for 2.X.X and things SHOULD be better...I hope! If you are not using any version of GD let me know and I will help you set it up. Its very simple and you just need to uncomment some lines in your php.ini file and you're good to go if you are using PHP v. 4.3.9 like I am.

    Look for the section in the tutorial where Mayank talks about the GD library, the differences between versions and specifically in your upload.php page:



    Everything remains the same as with the version 1.x.x code, except for the two different functions used:

    �� in place of ImageCreate, we used ImageCreateTrueColor.



    �� in place of ImageCopyResized, we used ImageCopyResampled.



    Mayank in his tutorial also talks about ImageMagick. I have no experience with this but incase you can not use or dont have access to the GD library, Imagemagick will do the graphics work you desire too. Some say its easier to use some say worse...personally, I'd stick with the GD library version 2.X.X.

    The version of PHP I stated I was using above DOES include support for the infamous "GIF" file format too since the patent expired worldwide. Mine works with GIF's.

    Ok so I am ranting a bit here... but I think you are on the right track. Here is the short version: Decide which, if any, version of the GD library is in use on your server and change the code's GD specific functions to the correct version. If all goes well, you should be in business barring some other error. Hope this all helps!



    Quote Originally Posted by jppp
    Now, when I go to try to upload my photographs, I get the following single error which I got last time too.

    Fatal error: Call to undefined function: imagecreatefromjpeg() in c:\ncdtree\my documents\php\example scripts\photogallery\upload.php on line 78
    PHP Code:
     
    // Build Thumbnail with GD 1.x.x, you can use the other described methods too
        
    $function_suffix $gd_function_suffix[$filetype]; // Line 78
        
    $function_to_read "ImageCreateFrom".$function_suffix;
        
    $function_to_write "Image".$function_suffix
    Well, I have downloaded the all my codes from the code archive, so there is no problem on that front.

    By the way, do I need to download GD? I thought that it was included as one of the functions of PHP. That alone should not be the reason for my fatal error, or is it?
    Drew

    "The town where I grew up has a zip code of E-I-E-I-O."

  7. #257
    SitePoint Enthusiast drewf's Avatar
    Join Date
    Mar 2002
    Location
    Calgary, AB
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you may have GIF related information in your file type array in upload.php. Its just a thought but check this and or post the code here in the forum thread so we can see why indeed you are getting this error.

    Here is my file type array that does not have GIF related index and key's in it but it could if you are using GD version 2.28:

    PHP Code:
    // List of our known photo types
            
    $known_photo_types = array( 
               
    'image/pjpeg' => 'jpg',
               
    'image/jpeg' => 'jpg',
               
    'image/bmp' => 'bmp',
               
    'image/x-png' => 'png');
            
            
    // GD Function Suffix List
            
    $gd_function_suffix = array( 
               
    'image/pjpeg' => 'JPEG',
               
    'image/jpeg' => 'JPEG',
               
    'image/bmp' => 'WBMP',
               
    'image/x-png' => 'PNG'); 
    Anyhow your program is complaining that that array indice doesn't exist.

    Undefined offset will mean that an array indice isn't set at the time of use.

    Line 35 pertains to if(!array_key_exists($photos_uploaded['type'][$counter], $known_photo_types)). See it checks for the existance of an array key. I think this has something to do with GIF related things. I am not sure how to articulate in words how to solve this in simple terms but I hope I have given you insight into the problem. I believe this forum thread does indeed tell you how to either remove the GIF stuff or add it...I can't remember where unfortunately, its a pretty LOOOOOOOOOONG thread!


    Quote Originally Posted by raindrops
    Hi,
    I've read thru all the threads but couldn't find an ans to this error:

    Notice: Undefined offset: 5 in c:\inetpub\wwwroot\videosig\photogallery\upload.php on line 35

    I really nd some help on this.. thank you!
    Drew

    "The town where I grew up has a zip code of E-I-E-I-O."

  8. #258
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Singapore
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    upload.php error

    Quote Originally Posted by raindrops
    Hi,
    I've read thru all the threads but couldn't find an ans to this error:

    Notice: Undefined offset: 5 in c:\inetpub\wwwroot\videosig\photogallery\upload.php on line 34

    I really nd some help on this.. thank you!
    Hi, this is my upload.php codes... i've downloaded it from the archive...

    PHP Code:
    <?php
        
    include("config.inc.php");

        
    // initialization
        
    $result_final "";
        
    $counter 0;

        
    // List of our known photo types
        
    $known_photo_types = array( 
                            
    'image/pjpeg' => 'jpg',
                            
    'image/jpeg' => 'jpg',
                            
    'image/gif' => 'gif',
                            
    'image/bmp' => 'bmp',
                            
    'image/x-png' => 'png'
                        
    );
        
        
    // GD Function List
        
    $gd_function_suffix = array( 
                            
    'image/pjpeg' => 'JPEG',
                            
    'image/jpeg' => 'JPEG',
                            
    'image/gif' => 'GIF',
                            
    'image/bmp' => 'WBMP',
                            
    'image/x-png' => 'PNG'
                        
    );

        
    // Fetch the photo array sent by preupload.php
        
    $photos_uploaded $_FILES['photo_filename'];

        
    // Fetch the photo caption array
        
    $photo_caption $_POST['photo_caption'];

        while( 
    $counter <= count($photos_uploaded) )
        {
            if(
    $photos_uploaded['size'][$counter] > 0)
            {
                if(!
    array_key_exists($photos_uploaded['type'][$counter], $known_photo_types))
                {
                    
    $result_final .= "File ".($counter+1)." is not a photo<br />";
                }
                else
                {
                    
    mysql_query"INSERT INTO gallery_photos(`photo_filename`, `photo_caption`, `photo_category`) VALUES('0', '".addslashes($photo_caption[$counter])."', '".addslashes($_POST['category'])."')" );
                    
    $new_id mysql_insert_id();
                    
    $filetype $photos_uploaded['type'][$counter];
                    
    $extention $known_photo_types[$filetype];
                    
    $filename $new_id.".".$extention;

                    
    mysql_query"UPDATE gallery_photos SET photo_filename='".addslashes($filename)."' WHERE photo_id='".addslashes($new_id)."'" );

                    
    // Store the orignal file
                    
    copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename);

                    
    // Let's get the Thumbnail size
                    
    $size GetImageSize$images_dir."/".$filename );
                    if(
    $size[0] > $size[1])
                    {
                        
    $thumbnail_width 100;
                        
    $thumbnail_height = (int)(100 $size[1] / $size[0]);
                    }
                    else
                    {
                        
    $thumbnail_width = (int)(100 $size[0] / $size[1]);
                        
    $thumbnail_height 100;
                    }
                
                    
    // Build Thumbnail with GD 1.x.x, you can use the other described methods too
                    
    $function_suffix $gd_function_suffix[$filetype];
                    
    $function_to_read "ImageCreateFrom".$function_suffix;
                    
    $function_to_write "Image".$function_suffix;

                    
    // Read the source file
                    
    $source_handle $function_to_read $images_dir."/".$filename ); 
                    
                    if(
    $source_handle)
                    {
                        
    // Let's create an blank image for the thumbnail
                             
    $destination_handle ImageCreateTrueColor $thumbnail_width$thumbnail_height );
                    
                        
    // Now we resize it
                          
    ImageCopyResampled$destination_handle$source_handle0000$thumbnail_width$thumbnail_height$size[0], $size[1] );
                    }

                    
    // Let's save the thumbnail
                    
    $function_to_write$destination_handle$images_dir."/tb_".$filename );
                    
    ImageDestroy($destination_handle );
                    
    //

                    
    $result_final .= "<img src='".$images_dir"/tb_".$filename."' /> File ".($counter+1)." Added<br />";
                }
            }
        
    $counter++;
        }

        
    // Print Result
    echo <<<__HTML_END

    <html>
    <head>
        <title>Photos uploaded</title>
    </head>
    <body>
        
    $result_final
    </body>
    </html>

    __HTML_END;
    ?>

  9. #259
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    714
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Drew,

    I am using version 4.3.1 of PHP. I used php_info.php to find out the version of GD but did not find GD mentioned anywhere. Does that mean that I do not have any version of GD installed? Anyway, I downloaded the GD library from www.Boutell.com. Now I just need to install it. I will take your help if needed.
    Thanks once again.

  10. #260
    SitePoint Enthusiast drewf's Avatar
    Join Date
    Mar 2002
    Location
    Calgary, AB
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jppp
    Drew,


    I am using version 4.3.1 of PHP. I used php_info.php to find out the version of GD but did not find GD mentioned anywhere. Does that mean that I do not have any version of GD installed? Anyway, I downloaded the GD library from www.Boutell.com. Now I just need to install it. I will take your help if needed.
    Thanks once again.
    Based on what you are saying above, I am concluding that you might have had GD version 2.x.x at least downloaded on your computer-just not configured right. I am thinking this because I see you successfully have PHP working at least, well guess what, GD is bundled with PHP when you download it-it just needs some help being recognized. PHP has a wonderful amount of features and modules that extend what the language can do beyond your dreams. The GD and PDF libraries are two of those extensions...

    Pre install-I am making some assumptions here: I am assuming you are running windows. I am running XP hope you are too...file paths may differ on win98 or 2000 but I can't remember as that's a long time ago. If so, you'll have to modify accordingly. You will be installing the LATEST version of GD from boutell.com overwriting your downloaded copy in your PHP folder.

    1) Shut down your apache web server (CTRL+C) shuts it down. This is required! You will re-start it once changes are made to the PHP.INI file I detail below. Its a good idea to shut down your MySQL server as well but its not required as they are separate programs. Just be safe.

    2) locate your PHP directory-the place you unzipped PHP to in the first place when you were installing it way back when. Naviagate to the extensions folder inside this tree structure. See mine, below, as an example. Yours may be different so compinsate accordingly. I stuck mine inside my Apache web server directory structure to keep things organized. Mine is: C:\apache\php\extensions

    3) inside this directory are the extensions that do crazy (GOOD) things with PHP. You are looking for a dll named php_gd2.dll. If you have this guess what? You have GD version 2 already on your computer! If not, put your freshly downloaded copy of the dll from Boutell.com in this folder. You ultimately want the above named dll in the extensions directory inside your PHP directory. I can't remember what the name of version 1 of the dll is, I think it just doesn't have the number 2 in it. If you find version 1 dll, delete it. You want version 2 and its named like I said above.

    4) locate your php.ini file and modify it accordingly. My php.ini file is in my C:\WINDOWS directory. Save a back-up of this file to be safe, you can delete this back up if all goes well. PHP.INI is your PHP bible so open this sucker in Notepad or Wordpad and do a search (CTRL +F) for gd. It will take you under a heading called ;Windows Extensions The semicolons are comments by the way, preventing that statement from being executed. All you have to do when you find ;extension=php_gd2.dll is delete the semicolon comment from this line. You will end up with extension=php_gd2.dll.

    5) you can uncomment the PDF related one too but its not required here. Who knows you may want to delve into the relm of auto PDF creation too one day. If so uncomment this line: extension=php_pdf.dll. Can't hurt right?

    6) save this file, be careful to not save it with a .txt extension. You do this by going SAVE AS and then putting the file name in quotes like this "php.ini". Overwrite you old one if it asks.

    7) restart your Apache web server. If all goes well and you get no errors in the dos box Apache screen you are set! Restart your MySQL server too if you have this installed and shut it down like I told you to. Not required but like I said, better get used to doing this to be safe.

    8) redo the php_info.php stuff I mentioned to you a few threads ago. It should now find a GD heading and list what version you have.

    9) modify your PHP code accordingly in upload.php with the GD version 2.x.x code mentioned in the tutorial.

    10) get yourself a drink and take a break! You are back in business!
    Drew

    "The town where I grew up has a zip code of E-I-E-I-O."

  11. #261
    SitePoint Enthusiast drewf's Avatar
    Join Date
    Mar 2002
    Location
    Calgary, AB
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by raindrops
    Hi, this is my upload.php codes... i've downloaded it from the archive...

    PHP Code:
    <?php
        
    include("config.inc.php");
     
        
    // initialization
        
    $result_final "";
        
    $counter 0;
     
        
    // List of our known photo types
        
    $known_photo_types = array( 
                            
    'image/pjpeg' => 'jpg',
                            
    'image/jpeg' => 'jpg',
                            
    'image/gif' => 'gif',
                            
    'image/bmp' => 'bmp',
                            
    'image/x-png' => 'png'
                        
    );
     
        
    // GD Function List
        
    $gd_function_suffix = array( 
                            
    'image/pjpeg' => 'JPEG',
                            
    'image/jpeg' => 'JPEG',
                            
    'image/gif' => 'GIF',
                            
    'image/bmp' => 'WBMP',
                            
    'image/x-png' => 'PNG'
                        
    );
     
        
    // Fetch the photo array sent by preupload.php
        
    $photos_uploaded $_FILES['photo_filename'];
     
        
    // Fetch the photo caption array
        
    $photo_caption $_POST['photo_caption'];
     
        while( 
    $counter <= count($photos_uploaded) )
        {
            if(
    $photos_uploaded['size'][$counter] > 0)
            {
                if(!
    array_key_exists($photos_uploaded['type'][$counter], $known_photo_types))
                {
                    
    $result_final .= "File ".($counter+1)." is not a photo<br />";
                }
                else
                {
                    
    mysql_query"INSERT INTO gallery_photos(`photo_filename`, `photo_caption`, `photo_category`) VALUES('0', '".addslashes($photo_caption[$counter])."', '".addslashes($_POST['category'])."')" );
                    
    $new_id mysql_insert_id();
                    
    $filetype $photos_uploaded['type'][$counter];
                    
    $extention $known_photo_types[$filetype];
                    
    $filename $new_id.".".$extention;
     
                    
    mysql_query"UPDATE gallery_photos SET photo_filename='".addslashes($filename)."' WHERE photo_id='".addslashes($new_id)."'" );
     
                    
    // Store the orignal file
                    
    copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename);
     
                    
    // Let's get the Thumbnail size
                    
    $size GetImageSize$images_dir."/".$filename );
                    if(
    $size[0] > $size[1])
                    {
                        
    $thumbnail_width 100;
                        
    $thumbnail_height = (int)(100 $size[1] / $size[0]);
                    }
                    else
                    {
                        
    $thumbnail_width = (int)(100 $size[0] / $size[1]);
                        
    $thumbnail_height 100;
                    }
     
                    
    // Build Thumbnail with GD 1.x.x, you can use the other described methods too
                    
    $function_suffix $gd_function_suffix[$filetype];
                    
    $function_to_read "ImageCreateFrom".$function_suffix;
                    
    $function_to_write "Image".$function_suffix;
     
                    
    // Read the source file
                    
    $source_handle $function_to_read $images_dir."/".$filename ); 
     
                    if(
    $source_handle)
                    {
                        
    // Let's create an blank image for the thumbnail
                         
    $destination_handle ImageCreateTrueColor $thumbnail_width$thumbnail_height );
     
                        
    // Now we resize it
                     
    ImageCopyResampled$destination_handle$source_handle0000$thumbnail_width$thumbnail_height$size[0], $size[1] );
                    }
     
                    
    // Let's save the thumbnail
                    
    $function_to_write$destination_handle$images_dir."/tb_".$filename );
                    
    ImageDestroy($destination_handle );
                    
    //
     
                    
    $result_final .= "<img src='".$images_dir"/tb_".$filename."' /> File ".($counter+1)." Added<br />";
                }
            }
        
    $counter++;
        }
     
        
    // Print Result
    echo <<<__HTML_END
     
    <html>
    <head>
        <title>Photos uploaded</title>
    </head>
    <body>
        
    $result_final
    </body>
    </html>
     
    __HTML_END;
    ?>
    ***Try this first***

    Remove this line from the // List of our known photo types array.
    PHP Code:
    'image/gif' => 'gif'
    AND remove this line from the // GD Function List:
    PHP Code:
    'image/gif' => 'GIF'
    Save your code and see if your errors happen again. Like I was saying several threads ago, you most likely don't have the latest and greatest GD library installed on your testing server or on your production server where ever you are trying out your php code from this tutorial. The latest GD library has GIF support in it. The old versions of the GD library DO NOT HAVE THIS FUNCTIONALITY because of patent issues. Do a google search on this if you need to know why...

    Anyhow, remember this, if you code your PHP pages to have the latest and greatest GIF support and they test fine on your home computer testing server but DO NOT work when you upload them to your production server (your host account somewhere on the planet) then their version of the GD library is different from the one you are using! They both have to be the same or you will run into error trouble!!!!!
    Drew

    "The town where I grew up has a zip code of E-I-E-I-O."

  12. #262
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    714
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Based on what you are saying above, I am concluding that you might have had GD version 2.x.x at least downloaded on your computer-just not configured right. I am thinking this because I see you successfully have PHP working at least, well guess what, GD is bundled with PHP when you download it-it just needs some help being recognized
    I did all that you had mentioned.
    Yes, I am running windows.

    I did the following:
    Shut down Apache web server and my MySQL server.
    Went to extensions directory and found php_gd2.dll.
    Located php.ini file and deleted the semicolon comment from ;extension=php_gd2.dll and also from ;extension=php_pdf.dll and then saved the php.ini file.
    I had no problems restarting my Apache web server and my MySQL web server.
    I redid php_info.php again.

    Now comes my problem.
    I can still see no GD heading in my php_info.php file. Still, I tried modifying the PHP code in upload.php with the GD version 2.x.x. code mentioned in the tutorial. As expected, it continued to give the same error.
    I don't understand why this is happening?

  13. #263
    SitePoint Enthusiast drewf's Avatar
    Join Date
    Mar 2002
    Location
    Calgary, AB
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey jppp, well thats good and bad news. I am glad you were able to find out about the GD dll at least being version 2. Now that your code is modified for the version 2 library, you have prevented further errors. But, I am concerned that you are unable to see your GD information in your php_info.php file when its run. I have attached a screenshot of what you should see, further down on the php_info.php page. Also make sure in your php.ini file this line is modified too: extension_dir = "c:/php/extensions" NOTE: SUBSTITUTE THE ACTUAL PHP INSTALLATION DIRECTORY ON *YOUR* COMPUTER.

    In a nutshell, what you are telling me is that your PHP configuration isn't recognizing the GD dll file. Without seeing your php configuration, I can not help you further unfortunately. I can point you to the GD FAQ on the Boutell site. Perhaps you can find futher information there. http://www.boutell.com/gd/faq.html as well as the PHP Manual here:
    http://livedocs.php.mirrors.powertri...xtensions.html

    Until you can get the GD information to appear in your php_info.php file you are "hooped" unfortunately. When you get this problem solved, come back and I'll see if I can help you futher. Sorry about this but getting your GD configuration to appear is a crucial step in the troubleshooting process.




    Quote Originally Posted by jppp
    I did all that you had mentioned.
    Yes, I am running windows.

    I did the following:
    Shut down Apache web server and my MySQL server.
    Went to extensions directory and found php_gd2.dll.
    Located php.ini file and deleted the semicolon comment from ;extension=php_gd2.dll and also from ;extension=php_pdf.dll and then saved the php.ini file.
    I had no problems restarting my Apache web server and my MySQL web server.
    I redid php_info.php again.

    Now comes my problem.
    I can still see no GD heading in my php_info.php file. Still, I tried modifying the PHP code in upload.php with the GD version 2.x.x. code mentioned in the tutorial. As expected, it continued to give the same error.
    I don't understand why this is happening?
    Attached Images Attached Images
    Drew

    "The town where I grew up has a zip code of E-I-E-I-O."

  14. #264
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Singapore
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by drewf
    ***Try this first***

    Remove this line from the // List of our known photo types array.
    PHP Code:
    'image/gif' => 'gif'
    AND remove this line from the // GD Function List:
    PHP Code:
    'image/gif' => 'GIF'
    Save your code and see if your errors happen again. Like I was saying several threads ago, you most likely don't have the latest and greatest GD library installed on your testing server or on your production server where ever you are trying out your php code from this tutorial. The latest GD library has GIF support in it. The old versions of the GD library DO NOT HAVE THIS FUNCTIONALITY because of patent issues. Do a google search on this if you need to know why...

    Anyhow, remember this, if you code your PHP pages to have the latest and greatest GIF support and they test fine on your home computer testing server but DO NOT work when you upload them to your production server (your host account somewhere on the planet) then their version of the GD library is different from the one you are using! They both have to be the same or you will run into error trouble!!!!!
    hey! i've solved the prob!!! jus change frm
    35 while( $counter <= count($photos_uploaded) )
    to
    35 while( $counter < count($photos_uploaded) )

    then the prob is solved!!! so happy!
    Thanks anyway! It's was ur explaination on the error tht helps a lot!

  15. #265
    SitePoint Member mecubetri's Avatar
    Join Date
    Dec 2004
    Location
    kansas city, MO
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help! No image

    I've uploaded all files to my site. Set the chmod to 777. My server uses Linux. and heres the problem.

    Starting at the preupload.php page everything works fine. I upload my image, give it a caption, and submit it.

    Once the upload.php page comes up though all I see is the caption with a broken image link next to it. If I go to viewgallery.php I can see the captions of the files I have uploaded but no image appears.

    I'm rather desperate here. I am building this site for my fiance's bridesmaids so they can upload images of ideas they have for dresses, etc so time is of the essence.

    Heres a link to my preupload.php site preupload.php
    and here is the code:
    <?php
    include("config.inc.php");

    // initialization
    $photo_upload_fields = "";
    $counter = 1;

    // default number of fields
    $number_of_fields = 5;

    // If you want more fields, then the call to this page should be like,
    // preupload.php?number_of_fields=20

    if( $_GET['number_of_fields'] )
    $number_of_fields = (int)($_GET['number_of_fields']);

    // Firstly Lets build the Category List

    $result = mysql_query( "SELECT category_id,category_name FROM gallery_category" );
    while( $row = mysql_fetch_array( $result ) )
    {
    $photo_category_list .=<<<__HTML_END
    <option value="$row[0]">$row[1]</option>\n
    __HTML_END;
    }
    mysql_free_result( $result );

    // Lets build the Photo Uploading fields
    while( $counter <= $number_of_fields )
    {
    $photo_upload_fields .=<<<__HTML_END
    <tr>
    <td>
    Photo {$counter}:
    <input name=' photo_filename[]' type='file' />
    </td>
    </tr>
    <tr>
    <td>
    Caption:
    <textarea name='photo_caption[]' cols='30' rows='1'></textarea>
    </td>
    </tr>
    __HTML_END;
    $counter++;
    }

    // Final Output
    echo <<<__HTML_END
    <html>
    <head>
    <title>Photo Upload - Corey and Justin's Wedding</title>
    </head>
    <body>
    <form enctype='multipart/form-data' action='upload.php' method='post' name='upload_form'>
    <table width='90%' border='0' align='center' style='width: 90%;'>
    <tr>
    <td>
    Select Category
    <select name='category'>
    $photo_category_list
    </select>
    </td>
    </tr>
    <tr>
    <td>
    <p>&nbsp;</p>
    </td>
    </tr>

    <!-Insert the photo fields here -->
    $photo_upload_fields

    <tr>
    <td>
    <input type='submit' name='submit' value='Add Photos' />
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    __HTML_END;
    ?>


    Here is the code to my upload.php
    <?php
    include("config.inc.php");

    // initialization
    $result_final = "";
    $counter = 0;

    // List of our known photo types
    $known_photo_types = array(
    'image/pjpeg' => 'jpg',
    'image/jpeg' => 'jpg',
    'image/gif' => 'gif',
    'image/bmp' => 'bmp',
    'image/x-png' => 'png'
    );
    $imagemagickPath = "/usr/local/bin/identify";
    exec("$imagemagickPath/convert -geometry " .
    "{$thumbnail_width}x{$thumbnail_height} " .
    "$images_dir/$filename $images_dir/tb_$filename");
    //convert –geometry <width>x<height> <source_path> <destination_path>



    //

    $result_final .= "<img src='".$images_dir. "/tb_".$filename."' /> File ".($counter+1)." Added<br />";
    $counter++;


    // Print Result
    echo <<<__HTML_END

    <html>
    <head>
    <title>Photos uploaded</title>
    </head>
    <body>
    $result_final
    </body>
    </html>

    __HTML_END;
    ?>

    Thanks for your help.

  16. #266
    SitePoint Member
    Join Date
    Nov 2004
    Location
    geneva
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello everyone. This gallery is awsome. I used it to implement automated image system on my photography site.
    I also liked the way Infizi implemented the NEXT - PREVIOUS image code on his page
    www.frenchtrip.infizi.com/view.php

    Any idea on how do this within the same category?
    I sent a PM but he didnt reply yet..

  17. #267
    SitePoint Enthusiast drewf's Avatar
    Join Date
    Mar 2002
    Location
    Calgary, AB
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by raindrops
    hey! i've solved the prob!!! jus change frm
    35 while( $counter <= count($photos_uploaded) )
    to
    35 while( $counter < count($photos_uploaded) )

    then the prob is solved!!! so happy!
    Thanks anyway! It's was ur explaination on the error tht helps a lot!
    Uh ok, well if it works for you then thats great, I still strongly think your solution is not the correct solution, but hey if you're happy then what the heck...

    The code works as posted by Mayank and no alterations are necessary. If you have to alter the code to make it work, you are most likely going down the wrong path. The code I posted in my zip file also works if configured correctly thanks to a collaboration of effort by many. Just my 2.5/8ths worth for what its worth...
    Drew

    "The town where I grew up has a zip code of E-I-E-I-O."

  18. #268
    SitePoint Enthusiast drewf's Avatar
    Join Date
    Mar 2002
    Location
    Calgary, AB
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mecubetri
    I've uploaded all files to my site. Set the chmod to 777. My server uses Linux. and heres the problem.

    Starting at the preupload.php page everything works fine. I upload my image, give it a caption, and submit it.

    Once the upload.php page comes up though all I see is the caption with a broken image link next to it. If I go to viewgallery.php I can see the captions of the files I have uploaded but no image appears.

    I'm rather desperate here. I am building this site for my fiance's bridesmaids so they can upload images of ideas they have for dresses, etc so time is of the essence.

    Heres a link to my preupload.php site preupload.php
    and here is the code:
    <?php
    include("config.inc.php");

    // initialization
    $photo_upload_fields = "";
    $counter = 1;

    // default number of fields
    $number_of_fields = 5;

    // If you want more fields, then the call to this page should be like,
    // preupload.php?number_of_fields=20

    if( $_GET['number_of_fields'] )
    $number_of_fields = (int)($_GET['number_of_fields']);

    // Firstly Lets build the Category List

    $result = mysql_query( "SELECT category_id,category_name FROM gallery_category" );
    while( $row = mysql_fetch_array( $result ) )
    {
    $photo_category_list .=<<<__HTML_END
    <option value="$row[0]">$row[1]</option>\n
    __HTML_END;
    }
    mysql_free_result( $result );

    // Lets build the Photo Uploading fields
    while( $counter <= $number_of_fields )
    {
    $photo_upload_fields .=<<<__HTML_END
    <tr>
    <td>
    Photo {$counter}:
    <input name=' photo_filename[]' type='file' />
    </td>
    </tr>
    <tr>
    <td>
    Caption:
    <textarea name='photo_caption[]' cols='30' rows='1'></textarea>
    </td>
    </tr>
    __HTML_END;
    $counter++;
    }

    // Final Output
    echo <<<__HTML_END
    <html>
    <head>
    <title>Photo Upload - Corey and Justin's Wedding</title>
    </head>
    <body>
    <form enctype='multipart/form-data' action='upload.php' method='post' name='upload_form'>
    <table width='90%' border='0' align='center' style='width: 90%;'>
    <tr>
    <td>
    Select Category
    <select name='category'>
    $photo_category_list
    </select>
    </td>
    </tr>
    <tr>
    <td>
    <p>&nbsp;</p>
    </td>
    </tr>

    <!-Insert the photo fields here -->
    $photo_upload_fields

    <tr>
    <td>
    <input type='submit' name='submit' value='Add Photos' />
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    __HTML_END;
    ?>


    Here is the code to my upload.php
    <?php
    include("config.inc.php");

    // initialization
    $result_final = "";
    $counter = 0;

    // List of our known photo types
    $known_photo_types = array(
    'image/pjpeg' => 'jpg',
    'image/jpeg' => 'jpg',
    'image/gif' => 'gif',
    'image/bmp' => 'bmp',
    'image/x-png' => 'png'
    );
    $imagemagickPath = "/usr/local/bin/identify";
    exec("$imagemagickPath/convert -geometry " .
    "{$thumbnail_width}x{$thumbnail_height} " .
    "$images_dir/$filename $images_dir/tb_$filename");
    //convert –geometry <width>x<height> <source_path> <destination_path>



    //

    $result_final .= "<img src='".$images_dir. "/tb_".$filename."' /> File ".($counter+1)." Added<br />";
    $counter++;


    // Print Result
    echo <<<__HTML_END

    <html>
    <head>
    <title>Photos uploaded</title>
    </head>
    <body>
    $result_final
    </body>
    </html>

    __HTML_END;
    ?>

    Thanks for your help.

    I am no ImageMagick expert at all, in fact I have 0% familiarity with it as I use GD, but I do know your code is working perfectly as I just uploaded a picture of a flower BUT...its just your path to your images folder that is not correct. Somehow, you need to adjust either your config.inc.php file to refer to the correct images or photos folder. Its just your path configuration...

    You only get a red X when the link to the requested image can not be found. The browser is trying to find it, same with the PHP code but with no luck...the path is broken somehow. Fix this and you should be good to go. Try a ./photos or something like that even a ../photos. Beacause I can't see your HTDOCS folder hirearchy I can't tell you what you should do to fix it...hopefully you can mess with it a bit and get it to work. You are
    <-- 'this close' --> to getting it to work. Good luck.
    Drew

    "The town where I grew up has a zip code of E-I-E-I-O."

  19. #269
    SitePoint Member mecubetri's Avatar
    Join Date
    Dec 2004
    Location
    kansas city, MO
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have tried everything (that I can think of) in my config.inc.php file. The images are getting downloaded but I can't seem to repair the broken link. Here is my hierarchy...

    /home/marley/www/photos

    Here is my config.ini.php file...

    <?php
    // Before implementing this code, you should use your own username, password and database name values.

    $mysql_link = mysql_connect("localhost", "marley", "cnd1221");
    mysql_select_db("bridesmaid") or die("db_Error - Please contact jwehrman@ascensiongraphics.com");

    $images_dir = "/home/marley/www/photos";
    ?>

    here is a snippet of the source when viewed over ie explorer...

    <tr>
    <td><a href='viewgallery.php?cid=1&pid=1'><img src='/home/marley/www/photos/tb_1.jpg' border='0' alt='road' /></a></td>
    <td><a href='viewgallery.php?cid=1&pid=2'><img src='/home/marley/www/photos/tb_2.jpg' border='0' alt='road' /></a></td>
    <td><a href='viewgallery.php?cid=1&pid=3'><img src='/home/marley/www/photos/tb_3.jpg' border='0' alt='road 2' /></a></td>
    <td><a href='viewgallery.php?cid=1&pid=4'><img src='/home/marley/www/photos/tb_4.jpg' border='0' alt='road 2' /></a></td>
    <td><a href='viewgallery.php?cid=1&pid=5'><img src='/home/marley/www/photos/tb_5.jpg' border='0' alt='road 2' /></a></td>

    </tr>

  20. #270
    SitePoint Member mecubetri's Avatar
    Join Date
    Dec 2004
    Location
    kansas city, MO
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  21. #271
    SitePoint Member mecubetri's Avatar
    Join Date
    Dec 2004
    Location
    kansas city, MO
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help! I'm going nuts with this.

  22. #272
    SitePoint Member mecubetri's Avatar
    Join Date
    Dec 2004
    Location
    kansas city, MO
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here are the warnings I get when I try changing my config.ini.php file to link to /www/photos


    Warning: move_uploaded_file(/www/photos/19.jpg): failed to open stream: No such file or directory in /home/marley/www/upload.php on line 51

    Warning: move_uploaded_file(): Unable to move '/tmp/php7FNL2A' to '/www/photos/19.jpg' in /home/marley/www/upload.php on line 51

    Warning: getimagesize(/www/photos/19.jpg): failed to open stream: No such file or directory in /home/marley/www/upload.php on line 54

    Warning: Division by zero in /home/marley/www/upload.php on line 62

    Warning: imagecreatefromjpeg(/www/photos/19.jpg): failed to open stream: No such file or directory in /home/marley/www/upload.php on line 72

    Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/marley/www/upload.php on line 84

    Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/marley/www/upload.php on line 85

  23. #273
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Finland
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey.
    First i wanna thank for the great tutorial, it was really easy to follow and i get it fully worked, but i have one problem.
    Is there any way to get the fullsize images open in a new window, without the same html part than in viewgallery.php?
    I have tried this:
    result_array[] = "<a target='_blank' href='viewgallery.php?cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /><br />".$row[1]."</a>";
    But it only opens a new window with the same design.
    So i want to see my fullsize images with different design (white background) than my thumbs.
    Any help would be appreciated.

  24. #274
    SitePoint Enthusiast drewf's Avatar
    Join Date
    Mar 2002
    Location
    Calgary, AB
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mecubetri, the first thing I see is that your $images_dir in your config.ini.php file is set incorrectly. It should be simply: $images_dir = "photos"; not the absolute path that you have in your config file.

    All the errors you are seeing are definitely path related. Your code is working fine I believe. If this simple fix does not remedy your errors, Private Message me with your FTP information (server ip address, username, password -do not post this info here in the forum) and I will log in and view your code and or modify it for you accordingly...Then you can change your password or what have you to restore your FTP security. By the way it would be a good idea to change your MySQL username and password too now that you have exposed this impt. info to all the readers of this forum thread. You might want to edit your post at the very least and remove this info...but I would strongly change your username and or password too.

    Quote Originally Posted by mecubetri
    Have tried everything (that I can think of) in my config.inc.php file. The images are getting downloaded but I can't seem to repair the broken link. Here is my hierarchy...

    /home/marley/www/photos

    Here is my config.ini.php file...

    <?php
    // Before implementing this code, you should use your own username, password and database name values.

    $mysql_link = mysql_connect("localhost", "marley", "cnd1221");
    mysql_select_db("bridesmaid") or die("db_Error - Please contact jwehrman@ascensiongraphics.com");

    $images_dir = "/home/marley/www/photos";
    ?>

    here is a snippet of the source when viewed over ie explorer...

    <tr>
    <td><a href='viewgallery.php?cid=1&pid=1'><img src='/home/marley/www/photos/tb_1.jpg' border='0' alt='road' /></a></td>
    <td><a href='viewgallery.php?cid=1&pid=2'><img src='/home/marley/www/photos/tb_2.jpg' border='0' alt='road' /></a></td>
    <td><a href='viewgallery.php?cid=1&pid=3'><img src='/home/marley/www/photos/tb_3.jpg' border='0' alt='road 2' /></a></td>
    <td><a href='viewgallery.php?cid=1&pid=4'><img src='/home/marley/www/photos/tb_4.jpg' border='0' alt='road 2' /></a></td>
    <td><a href='viewgallery.php?cid=1&pid=5'><img src='/home/marley/www/photos/tb_5.jpg' border='0' alt='road 2' /></a></td>

    </tr>
    Drew

    "The town where I grew up has a zip code of E-I-E-I-O."

  25. #275
    Obsessive designer Infizi's Avatar
    Join Date
    May 2004
    Location
    North Pole
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "<a target='_blank' href='$images_dir.$row[2]'."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /><br />".$row[1]."</a>";

    Quote Originally Posted by duris
    Hey.
    First i wanna thank for the great tutorial, it was really easy to follow and i get it fully worked, but i have one problem.
    Is there any way to get the fullsize images open in a new window, without the same html part than in viewgallery.php?
    I have tried this:
    result_array[] = "<a target='_blank' href='viewgallery.php?cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /><br />".$row[1]."</a>";
    But it only opens a new window with the same design.
    So i want to see my fullsize images with different design (white background) than my thumbs.
    Any help would be appreciated.


Bookmarks

Posting Permissions

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