SitePoint Sponsor

User Tag List

Page 5 of 31 FirstFirst 12345678915 ... LastLast
Results 101 to 125 of 767
  1. #101
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    Morristown, TN
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Anonymous
    I want to put a next and back button on the viewgallery.php Full Size
    View page. Anyone know how to do that?
    would the buttons be for navigating thru several pages of one category or for switching between categories?

  2. #102
    SitePoint Guru Raskolnikov's Avatar
    Join Date
    Jul 2003
    Location
    USA
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Warnings

    I am trying to get this tutorial code to work, but i get these error messages when i push the upload button. I have pretty much only manipulated the few lines that needed to be manipulated. I wanted to make sure everything was working with this before i started tearing it apart, and fitting it to my needs.

    I have created the "photos" directory. and i un-commented the line in my php.ini "extensions=php_gd2". and the extensions_dir is pointing to the right directory. I have worked the code over with my minimal knowledge base, and come up empty handed.

    If you need to see code let me know, but these are the warning messages. I was wandering if any of you have gotten them, and know a fix.

    Warning: copy(photos/6.jpg): failed to open stream: Permission denied in D:\wwwroot\admin\photo_gallery\upload.php on line 51

    Warning: getimagesize(photos/6.jpg): failed to open stream: No such file or directory in D:\wwwroot\admin\photo_gallery\upload.php on line 54

    Warning: Division by zero in D:\wwwroot\admin\photo_gallery\upload.php on line 62

    Fatal error: Call to undefined function: imagecreatefromjpeg() in D:\wwwroot\admin\photo_gallery\upload.php on line 72

  3. #103
    SitePoint Guru Raskolnikov's Avatar
    Join Date
    Jul 2003
    Location
    USA
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    alright....i figured out the three warnings, i did not have Write permissions on that folder. But i am still getting the Fatal error.

  4. #104
    SitePoint Guru Raskolnikov's Avatar
    Join Date
    Jul 2003
    Location
    USA
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    where there is a will there is a way........BTW you have to reboot your server after you change your php.ini to enable php_gd2

    thanks

  5. #105
    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 animal777
    would the buttons be for navigating thru several pages of one category or for switching between categories?
    I too am interested in this navigation. I know how to implement some pagination but its very cumbersome and I don't have a clue how to implement it into this image gallery.

    I would think the navigation should be used to navigate through several images in ONE particular category at a time. Animal777, any insight would be greatly appreciated.

    Thanks,
    Drew

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

  6. #106
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    Morristown, TN
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by drewf
    I would think the navigation should be used to navigate through several images in ONE particular category at a time. Animal777, any insight would be greatly appreciated.
    Ok, here's my take on it. I don't see an easy way to nav thru the full size images because of the way that query is made.

    Code:
    $result = mysql_query( "SELECT photo_caption,photo_filename
     FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" );
    The query would have to be changed to include the category_id. But then you are only fetching 1 picture. IE, nothing to nav thru.

    The way I envisioned it working was to set a maximum number of thumbnails on one page, and have links to nav thru the pages.

  7. #107
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    Morristown, TN
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Next and Previous Navigation

    It's HERE!!!! Navigation for thumbnails. I have a trial gallery setup to test this code on. The resulting code can be found here:

    http://www.anglersforchrist.com/gallery/viewgallery.txt

    The nav code uses the limit clause on the mysql query to limit you to a set number of pictures to display. This is currently set to 10. Links are made for "next" and "previous".

    PHP Code:
    if(!isset($start)) $start 0;
    $result mysql_query"SELECT photo_id,photo_caption,photo_filename FROM gallery_photos
    WHERE photo_category='"
    .addslashes($cid)."' LIMIT " $start ", 10"); 
    PHP Code:
    $query "SELECT count(*) as count FROM gallery_photos 
    WHERE photo_category="
    .addslashes($cid); 

    $count_result mysql_query($query);
    $row mysql_fetch_array($count_result);
    $numrows $row['count'];
                
    if(
    $start 0){

    $result_final .= "<tr>\n<td>\n";
    $result_final .= "<a href=\"" $PHP_SELF "?cid=".$cid."
         &start=" 
    . ($start 10) ."\">Previous</a>\n</td>\n</tr>";
    }
    if (
    $numrows > ($start 10)){

    $result_final .= "<tr>\n<td>\n";
    $result_final .= "<a href=\"" $PHP_SELF "?cid=".$cid."
         &start=" 
    . ($start 10) ."\">Next</a>\n</td>\n</tr>";


  8. #108
    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 animal777
    It's HERE!!!! Navigation for thumbnails. I have a trial gallery setup to test this code on. The resulting code can be found here:

    http://www.anglersforchrist.com/gallery/viewgallery.txt

    The nav code uses the limit clause on the mysql query to limit you to a set number of pictures to display. This is currently set to 10. Links are made for "next" and "previous".
    PHP Code:
    if(!isset($start)) $start 0;
    $result mysql_query"SELECT photo_id,photo_caption,photo_filename FROM gallery_photos
    WHERE photo_category='"
    .addslashes($cid)."' LIMIT " $start ", 10" ); 
    PHP Code:
    $query "SELECT count(*) as count FROM gallery_photos 
    WHERE photo_category="
    .addslashes($cid); 

    $count_result mysql_query($query);
    $row mysql_fetch_array($count_result);
    $numrows $row['count'];

    if(
    $start 0){

    $result_final .= "<tr>\n<td>\n";
    $result_final .= "<a href=""\"" $PHP_SELF "?cid=".$cid."
    &start=" 
    . ($start 10) ."\">Previous</a>\n</td>\n</tr>";
    }
    if (
    $numrows > ($start 10)){

    $result_final .= "<tr>\n<td>\n";
    $result_final .= "<a href=""\"" $PHP_SELF "?cid=".$cid."
    &start=" 
    . ($start 10) ."\">Next</a>\n</td>\n</tr>";

    Way to go Animal777! I will take a look at your code and try to implement it myself. This pagination of thumbnails is pretty much like other forms of pagination and I am thinking about coming up with a way to show navigation status: ie. showing thumbnails 1 to 10 of 20 for example. That way one knows where they are in the picture jungle.

    Update: I have tried to implement your code but my pages do not link to the next one for some reason. I have simply copied and pasted your .TXT code into my own and for some reason it does not work. I have only changed all references to 10 (being the offset and number of thumbs to display on a page) to 5. In all cases in your above code. I do get a next link but when you click on it nothing happens. I thought this was because you used $PHP_SELF instead of $_SERVER['PHP_SELF'] but assigning $PHP_SELF=$_SERVER['PHP_SELF']; in the code still does not solve the problem.

    There is no other difference in your code and my code. So for mine not to work makes me wonder why it doesn't seem to link properly...ho hum.

    Anyhow I won't give up. I will see what I can come up with too.
    Last edited by drewf; Oct 23, 2003 at 10:09. Reason: Updated forum message
    Drew

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

  9. #109
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    Morristown, TN
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    category navigation with page numbering

    Quote Originally Posted by drewf
    I am thinking about coming up with a way to show navigation status: ie. showing thumbnails 1 to 10 of 20 for example. That way one knows where they are in the picture jungle.
    like this?
    http://www.anglersforchrist.com/gall...ery.php?cid=55

    I don't know why it isn't working for you... try the new code. I have added page numbering.
    http://www.anglersforchrist.com/gallery/viewgallery.txt

  10. #110
    SitePoint Guru Raskolnikov's Avatar
    Join Date
    Jul 2003
    Location
    USA
    Posts
    606
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just copied and pasted your code, and it work great! However, i am confused with the <<<HTML and __End_HTML. I am unfamilier with these html commands. I have looked around, but all i have learned is that i am more confused about the situation than i was when i started.

    I also was wandering how i can include my design template with this code? I have two include lines that create the HTML before the output, and after. but these HTML tags are confusing me.

    aside from that, the gallery looks great!

  11. #111
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    Morristown, TN
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raskolnikov
    I just copied and pasted your code, and it work great! However, i am confused with the <<<HTML and __End_HTML. I am unfamilier with these html commands. I have looked around, but all i have learned is that i am more confused about the situation than i was when i started.
    http://www.sitepointforums.com/showp...2&postcount=65

    you should read the entire thread to see how we got here.

    You can add your template in the html section in the bottom of the code. I am using dreamweaver and I have a template running on my real gallery.

    http://www.anglersforchrist.com/test...lery.php?cid=1

    I am changing the code to further enhance the navigation. I picked up the style that is used on this forum and was trying to duplicate it. Keep checking in to see new changes.

    http://www.anglersforchrist.com/gall...?cid=55&page=1

    http://www.anglersforchrist.com/gallery/viewgallery.txt

  12. #112
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good Work

  13. #113
    SitePoint Enthusiast drewf's Avatar
    Join Date
    Mar 2002
    Location
    Calgary, AB
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Animal777, thank you for your re-post of your code. It works very well. I am tweaking the code also to display the navigation text for my needs. I appreciate you taking the time to post this code for us. I will still be checking this thread over time to see how things have developed further. Take care and thank you again!
    Drew

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

  14. #114
    SitePoint Evangelist netkid's Avatar
    Join Date
    Jun 2003
    Location
    USA
    Posts
    563
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't change anything or write the script, just dled it...all i did was fix the config file and then I added the tables to the database....my error in upload.php

    Fatal error: Call to undefined function: imagecreatefromjpeg() in /home/.foody/netkid/blog.net-kid.net/photogallery/upload.php on line 72
    You can try it at blog.net-kid.net/photogallery/preupload.php

    upload any pic that is supported, please keep it appropriate...

    Line 72:

    PHP Code:
    // Read the source file
    $source_handle $function_to_read $images_dir."/".$filename ); 

    Entire Code:

    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 ImageCreate $thumbnail_width$thumbnail_height );
                    
                        
    // Now we resize it
                          
    ImageCopyResized$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;
    ?>

    I contacted my host thinking it was the lack of one of the programs but they had it and told me to put this in my .htaccess file:


    AddType php-cgi php

    Thanks in advance!

    Santosh Sankar
    Bullish Bankers

  15. #115
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    Morristown, TN
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by netkid
    I didn't change anything or write the script, just dled it...all i did was fix the config file and then I added the tables to the database....my error in upload.php
    try my upload.php

    http://www.anglersforchrist.com/gallery/upload.txt

  16. #116
    SitePoint Evangelist netkid's Avatar
    Join Date
    Jun 2003
    Location
    USA
    Posts
    563
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thanks i will

    Santosh Sankar
    Bullish Bankers

  17. #117
    SitePoint Evangelist netkid's Avatar
    Join Date
    Jun 2003
    Location
    USA
    Posts
    563
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    same erro r

    Santosh Sankar
    Bullish Bankers

  18. #118
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    Morristown, TN
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by netkid
    same erro r
    have you done a phpinfo() to see if your host has GD installed?

  19. #119
    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 animal777
    What is was wondering is how I could limit the width of the picture to about 400 pixels. I know a separate resize function would need to be written, but I cannot figure out how to implement it.

    Any help would be appreciated.
    I am also wondering how to limit my fullsize picture to a desired size as some of my pics break my site's design. I am wondering if anyone has any insight into adding this re-sizing of the full sized pic feature to the tutorial's code that we have all been using.

    Thanks all...
    Drew

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

  20. #120
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How will this code delete the pictures from the database?

    I've played with this for a long time and the thing is this will only delete the large image not the thumbnail and if one fails it doesnt delete the entry from the database anyway.

    here is the delete function I have been using

    PHP Code:
    // Delete a picture from the database
    if(isset($_REQUEST['delete_photo'])) {
        
    $photo_id $_REQUEST['delete_photo'];
        
    $cid $_REQUEST['cid'];
            if(
    $photo_id != "" && $cid != "") {
                
    delete_photo($photo_id);
                
    $result_final .= "<br/><p style='color: green; font-weight: bold;'>Photo ID: $photo_id has been deleted from the database.</p>";
            } else {
                
    $result_final .= "<br /><p style='color: red; font-weight: bold;'>Their was an error in deleting the requested image please go back and try again.</p>";
            }
     } 
    Thanks for your help

  21. #121
    SitePoint Zealot Scout141's Avatar
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    137
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just anFYI. This tutorial worked great for me, except my thumbnails that were being produced were grainy and washed out.

    After doing some poking around, I came across a script that also generated thumbnails, but it used
    'ImageCreateTrueColor' rather than 'ImageCreate'.

    So, at this point:
    PHP Code:
    if($source_handle)
                    {
                        
    // Let's create an blank image for the thumbnail
                             
    $destination_handle ImageCreate $thumbnail_width$thumbnail_height ); 
    I replaced the ImageCreate, and the thumbnails being generated were now clear and colourful...

    PHP Code:
    if($source_handle)
                    {
                        
    // Let's create an blank image for the thumbnail
                             
    $destination_handle ImageCreateTrueColor $thumbnail_width$thumbnail_height ); 
    The ramifications of this change? Other than nicer thumbnails, I really don't know.... sigh... wish I knew more about php... but working on it!

    If anyone could shed some light on this, I'd be curious...


  22. #122
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How will this code delete the pictures from the database?

    I've played with this for a long time and the thing is this will only delete the large image not the thumbnail and if one fails it doesnt delete the entry from the database anyway.

    here is the delete function I have been using
    PHP Code:
    // Deleting a photo
    function delete_photo($photo_id) {
    $query "SELECT photo_filename FROM gallery_photos WHERE photo_id = '" addslashes($photo_id) . "'";
    $result mysql_query($query) or die("<p style='color: red; font-weight: bold;'>Their was an error while trying to delete the photo from the database.<br />".mysql_error()."</p>" );
    list(
    $filename) = mysql_fetch_array($result);
    mysql_free_result($result);

    # unlink($_SERVER[DOCUMENT_ROOT]."/".$images_dir."/tb_".$filename);
    unlink($_SERVER[DOCUMENT_ROOT]."/".$images_dir."/".$filename);

    $query "DELETE FROM gallery_photos WHERE photo_id = '"addslashes($photo_id) ."'";
    mysql_query($query);

    here is the top part of the script which calls that function
    PHP Code:
    // Delete a picture from the database
    if(isset($_REQUEST['delete_photo'])) {
    $photo_id $_REQUEST['delete_photo'];
    $cid $_REQUEST['cid'];
    if(
    $photo_id != "" && $cid != "" ) {
    delete_photo($photo_id);  // calls the delete_photo() function
    $result_final .= "<br/><p style='color: green; font-weight: bold;'>Photo ID: $photo_id has been deleted from the database.</p>";
    } else {
    $result_final .= "<br /><p style='color: red; font-weight: bold;'>Their was an error in deleting the requested image please go back and try again.</p>";
    }

    Thanks for your help
    Last edited by noddy; Oct 28, 2003 at 03:56.

  23. #123
    SitePoint Member
    Join Date
    Oct 2003
    Location
    York, UK
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm having trouble telling the config.inc.php file what my mysql password is... i can't code php so you'll have to forgive me... i'm not sure where to declare my password in the file... can anyone help?

  24. #124
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jonic
    i'm having trouble telling the config.inc.php file what my mysql password is... i can't code php so you'll have to forgive me... i'm not sure where to declare my password in the file... can anyone help?
    its like this
    PHP Code:
     function dbConnect() {
    $mysql mysql_connect'localhost''your_username''your_password' );
        if(!
    $mysql)
        {
          echo 
    "Cannot connect to database" mysql_error();
          exit;
        }
        
    // select the appropriate database
        
    $mysql mysql_select_db'Your_database_name' );
        if(!
    $mysql)
        {
          echo 
    "Cannot select database." mysql_error();
          exit;
        }

    $mysql = mysql_connect( 'localhost', 'your_username', 'your_password' );
    localhost tellls the server that the mysql server is on the local machine
    your_sername is your mysql username you have had\set up for your database
    your_password is the password that your talking about and goes at the end of the line you can find more information at the www.mysql.com website.

    hope that helps

  25. #125
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    Morristown, TN
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jonic
    i'm having trouble telling the config.inc.php file what my mysql password is... i can't code php so you'll have to forgive me... i'm not sure where to declare my password in the file... can anyone help?
    PHP Code:
    <?php
        
    // Before implementing this code, you should use your own username, password and database name values.

        
    $mysql_link mysql_connect("localhost""username""password");   
        
    mysql_select_db("database_name") or die("Could not select database");

        
    $images_dir "photos";
    ?>


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
  •