SitePoint Sponsor

User Tag List

Page 28 of 31 FirstFirst ... 182425262728293031 LastLast
Results 676 to 700 of 767
  1. #676
    SitePoint Enthusiast
    Join Date
    Oct 2008
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind i figured it out. the config file needed some adjustments made to it

    Thankyou

  2. #677
    Fully Sweet Car noddy's Avatar
    Join Date
    Aug 2002
    Location
    Perth, Western Australia
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was going to add probably should have added a debug for the file path too.

    May pay for you to make a quick simple folder_debug() that has something like the below


    PHP Code:

    echo "<pre>The folder path is: ".$folder_path."</pre>";

    if (!
    file_exists($folder_path))
    {
      echo 
    "<pre>folder ".$folder_path." does not exist!</pre>\n";
    }

    if (!
    is_readable($folder_path))
    {
      echo 
    "<pre>folder ".$folder_path." not readable!</pre>\n";
    }

    if (!
    is_writable($folder_path))
    {
      echo 
    "<pre>folder ".$folder_path." not writable!</pre>\n";


    Always when adding files to folders its best to check it exists and you can write to it. If you can't or it doesn't exist then have your code automatically make it.

    Also saves you from having to manually create the folders and set the permissions.

  3. #678
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using Mayank Gandhi's tutorial to build a photo gallery myself.

    Thanks to my Sitepoint friends, I have got the following things in order.

    1. I have a gallery page (viewgallery.php) which contains the various thumbnail categories of images. Upon clicking the thumbnails, I am taken to the page containing the thumbnails of all the photos in that category. Upon clicking a thumbnail on that page,I am taken to the page containing the full image.

    2. I have next and previous links in my page containing the full image.

    3. I have an admin.php page where I can add, edit and delete categories.

    I am now trying to make a page to edit the photos ie I should be able to move a photo from one category to another and also change the caption of the photo.
    I have tried using the script in the zip file posted by Drew but I am going wrong somewhere.

    The following is the first part of my code.
    PHP Code:
    <?php
     
        
    include("config.inc.php");
         if( empty(
    $_POST['action']) )
        {
        
    // Firstly Lets get the Photo ID
     
     
    $result mysql_query("SELECT photo_caption,photo_filename,photo_category FROM gallery_photos WHERE
    photo_id = '"
    .addslashes($_POST['photo_id'])."'")
    or die(
    mysql_error());
    $nr mysql_num_rows($result);
    if( 
    $nr )
        {
            echo(
    "Photo not found in DB!");
    }
     
              
    $row mysql_fetch_array$result );
        
    mysql_free_result$result );
        echo(
    "Picture ID: ".$_POST['photo_id']."<br><br>");
        echo(
    "<a href='viewgallery.php?cid=".$row['photo_category']."&pid=".$_POST['photo_id']."'><img src='".$images_dir."/tb_".$row[1]."' border='0' alt='".$row[0]."' /></a>");
    I am getting the echoed message, "Photo not found in DB!" on the top followed by the form fields to move and update the photos, update the caption etc. but of course, they do not work as my query is not returning any data. I am not able to understand where I am going wrong.

  4. #679
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Is the photo id being sent?

  5. #680
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, Spence (thanks for helping), there is no photo id being returned. After the line, 'Photo not found in DB', there is a link to a missing photo which when clicked takes me to my gallery page and my address bar reads http://127.0.0.1/pvCom/viewgallery.php?cid=&pid=

    I am attaching a screenshot of what I can see on my screen when I click on editphoto.php
    Attached Images Attached Images

  6. #681
    SitePoint Member
    Join Date
    Sep 2008
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great article, I look forward to building it myself.

  7. #682
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by jppp View Post
    No, Spence (thanks for helping), there is no photo id being returned. After the line, 'Photo not found in DB', there is a link to a missing photo which when clicked takes me to my gallery page and my address bar reads http://127.0.0.1/pvCom/viewgallery.php?cid=&pid=

    I am attaching a screenshot of what I can see on my screen when I click on editphoto.php
    At this stage the screen shot has not been approved but at my guess is you need to look at why the photo id is not being sent. Is the page before setup to post the id over to the page above?


    Maybe show the page thats sending the photo id which will help us.

  8. #683
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is the page before setup to post the id over to the page above?
    I am sorry, Spence, I did not really understand the sentence above.

    I think I am overall confused with the method of editing the photos and have not understood the available code properly. How does one select the photo to be updated? Can the photo ids be displayed on the page and then can I select the photo that needs to be updated? (Isn't that what we did when we had to delete the photos?) I am going through the code posted by Drew and trying to understand it.
    I will give the code which I have been trying below:

    PHP Code:
    <?php
     
        
    include("config.inc.php");
     
        if( empty(
    $_POST['action']) )
        {
        
    // Firstly Lets get the Photo ID
     
     
    $result mysql_query("SELECT photo_caption,photo_filename,photo_category FROM gallery_photos WHERE
    photo_id = '"
    .addslashes($_POST['photo_id'])."'")
    or die(
    mysql_error());
    $nr mysql_num_rows($result);
    if( 
    $nr )
        {
            echo(
    "Photo not found in DB!");
    }
     
              
    $row mysql_fetch_array$result );
        
    mysql_free_result$result );
        echo(
    "Picture ID: ".$_POST['photo_id']."<br><br>");
     
        echo(
    "<a href='viewgallery.php?cid=".$row['photo_category']."&pid=".$_POST['photo_id']."'><img 
    src='"
    .$images_dir."/tb_".$row[1]."' border='0' alt='".$row[0]."' /></a>");
        
    // Firstly Lets build the Category List
        
    $result mysql_query"SELECT category_id,category_name FROM gallery_category" );
        while( 
    $row2 mysql_fetch_array$result ) )
        {
            if( 
    $row2["category_id"] == $row["photo_category"] )
            {
    $category_list .=<<<__HTML_END
        <option value="$row2[0]" selected>$row2[1]</option>\n
    __HTML_END;
            }
            else
            {
    $category_list .=<<<__HTML_END
        <option value="$row2[0]">$row2[1]</option>\n
    __HTML_END;
            }
        }
        
    mysql_free_result$result );
        
    $category_list '<select name="category_id">'.$category_list.'</select>';
    ?>
    <form name="photo_move" action="edit_photo.php" method="post">
    <b>Move Photo / Update Caption:</b><br />
    Select New Category: <?php echo($category_list); ?><br /><br />
    Update Caption: <input type="text" name="caption" value="<?php echo($row["photo_caption"]); ?>" /><br />
    <input type="hidden" value="<?php echo($_POST['photo_id']); ?>" name="photo_id" />
    <input type="submit" value="Submit" name="action" />
    </form>
    <br />
    <form name="photo_delete" action="edit_photo.php" method="post">
    <b>Delete Photo:</b><br />
    <input type="hidden" value="<?php echo($_POST['photo_id']); ?>" name="photo_id" />
    <input type="submit" value="Delete This Photo?" name="action" onclick="return confirm('Are you sure you want to do delete 
    this photo?')" />
    </form>
    <a href="admin.php">Back to Administration Page</a>
    <?php
        
    }
        else
        {
            if( 
    strcasecmp($_POST['action'], "Submit")==&& !empty( $_POST['category_id'] ) )
            {
                
    edit_photo($_POST['photo_id'], $_POST['caption'], $_POST['category_id']);
            }
            else if( 
    strcasecmp($_POST['action'], "Delete This Photo?")==&& !empty( $_POST['photo_id'] ) )
            {
                
    delete_photo($_POST['photo_id']);
            }
            else
            {
                echo(
    "Action not understood"); exit;
            }
            echo(
    "Process completed!");
            echo(
    "<br><a href='admin.php'>Back to Administration Page</a>");
        }
    // the functions here
    function edit_photo$photo_id$new_caption$new_category )
    {
    mysql_query"UPDATE gallery_photos SET photo_caption='".addslashes$new_caption )."', photo_category='".addslashes
    $new_category )."' WHERE photo_id='".addslashes$photo_id )."'"  );
    }
    function 
    delete_photo($photo_id)
    {
    global 
    $images_dir;
    $result mysql_query("
       SELECT photo_filename
       FROM gallery_photos
       WHERE photo_id = '" 
    addslashes($photo_id) . "'
    "
    );
    list(
    $filename) = mysql_fetch_array($result);
    mysql_free_result($result);
    unlink($images_dir '/' $filename);
    unlink($images_dir '/tb_' $filename);
    mysql_query("
       DELETE FROM gallery_photos
       WHERE photo_id='" 
    addslashes($photo_id) . "'
    "
    );
    }
    ?>

  9. #684
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    For each mysql query they will always start with a syntax command either:


    • Select
    • Update
    • Delete
    • Insert
    • Plus more...

    The ones your interested in is Select, Update and Delete. The Select command is to tell the query you would like information from the database. You will need to give it some parameters, one for which table to look in, the information you would like, e.g. - fullname, photo_id, etc... and one for any conditions to match.

    Update command is to update a line within a table, again this requires which cells to look at for each line, the table name and then the updated code.

    Delete is very simple but can be complicated if certain parameters are needed. The table name is only needed here with a Where clause to match any requirements needed, e.g. - DELETE FROM MYTABLE WHERE fullname = "Joe Doh".

    More information can be found at mysql.com, just make sure you know what mysql version your server is using before searching.

  10. #685
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot, Spence.

    I have a very newbie doubt. When we need to edit the photos, do we need to have 2 pages for it?
    eg. one page containing the list of photos with a link, edit photo besides each photo. Then when we click on the link, we are lead to the page, editphoto.php containing the above code. Is that how I should go about it? Maybe that is where I went wrong. The photo id is not being sent because I have not even selected a photo id. Am I right?

  11. #686
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, can't the edit photo link be a part of the admin.php page itself where I am adding, editing and deleting categories?

  12. #687
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by jppp View Post
    Thanks a lot, Spence.

    I have a very newbie doubt. When we need to edit the photos, do we need to have 2 pages for it?
    eg. one page containing the list of photos with a link, edit photo besides each photo. Then when we click on the link, we are lead to the page, editphoto.php containing the above code. Is that how I should go about it? Maybe that is where I went wrong. The photo id is not being sent because I have not even selected a photo id. Am I right?
    Quote Originally Posted by jppp View Post
    Also, can't the edit photo link be a part of the admin.php page itself where I am adding, editing and deleting categories?
    Yes thats correct to both. You will need a first page with a list of links (with thumbnails if you wish) and then direct it to the edit page. This can be used within the admin section.

    If you are thinking to use the pages for the user then modify it to only show their own.

  13. #688
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a page ListEdit.php where I have written the code for listing out the photos to be edited with a 'Edit this photo' link next to each photo. When the link is clicked, I am taken to the editphoto.php page (the code of which I had posted earlier and also sent the screenshot), but only the category id is being sent there. The photo id is not being sent. I have racked my brain for a long time but am just not able to find out what I am missing out? I need some help to do this.
    The following is the code of my page containing the list of photos to be edited.
    PHP Code:
    <?php
           
    include("config.inc.php");
    echo 
    "<p>Click the photo that needs to be edited: " 
    "</p>";
    //Display all photos with a "Edit this photo" link 
    next to each.
    $query "SELECT * FROM gallery_photos";
    $result1 mysql_query($query);
    while (
    $row mysql_fetch_array($result1) ) {
      
    $photo_id $row["photo_id"];
      
    $photo_filename $row["photo_filename"];
    echo(
    "<a href='edit_photo.php?cid=".$row
    ['photo_category']."&pid=".$_row['photo_id']."'><img 
    src='"
    .$images_dir."/tb_".$row[1]."' border='0' 
    alt='"
    .$row[0]."' />Edit this photo</a>");
     }
    ?>

  14. #689
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Below is the new code you need to use. The code on the next page is looking for data from photo_id,...

    First page:
    PHP Code:
    <?php
           
    include("config.inc.php");
    echo 
    "<p>Click the photo that needs to be edited: " 
    "</p>";
    //Display all photos with a "Edit this photo" link 
    next to each.
    $query "SELECT * FROM gallery_photos";
    $result1 mysql_query($query);
    while (
    $row mysql_fetch_array($result1) ) {
      
    $photo_id $row["photo_id"];
      
    $photo_filename $row["photo_filename"];
    echo(
    "<a href='edit_photo.php?photo_id=".$row
    ['photo_id']."'><img 
    src='"
    .$images_dir."/tb_".$row[1]."' border='0' 
    alt='"
    .$row[0]."' />Edit this photo</a>");
     }
    ?>
    but you are sending the id number by url so you will need to find and change "$_POST['photo_id']" to "$_GET['photo_id']". To make it a bit more secure check the code below:

    Second page:
    PHP Code:
    <?php
     
    include("config.inc.php");
     
    // collect and check the data sent by url is a number
    $phoid = (int)($_GET['photo_id']);
        
    // Check $phoid is not empty
    if(!empty($phoid) )
    {

    // Firstly Lets get the Photo ID
    $result mysql_query("SELECT photo_caption,photo_filename,photo_category FROM gallery_photos WHERE
    photo_id = '"
    .addslashes($phoid)."'")
    or die(
    mysql_error());
    $nr mysql_num_rows($result);
        if( 
    $nr )
        {
            echo(
    "Photo not found in DB!");
        }
        else
        { 
            
    $row mysql_fetch_array$result );
            
    mysql_free_result$result );
            echo(
    "Picture ID: ".$phoid."<br><br>");
     
            echo(
    "<a href='viewgallery.php?cid=".$row['photo_category']."&pid=".$phoid."'><img 
    src='"
    .$images_dir."/tb_".$row[1]."' border='0' alt='".$row[0]."' /></a>");
            
    // Firstly Lets build the Category List
            
    $result mysql_query"SELECT category_id,category_name FROM gallery_category" );
            while( 
    $row2 mysql_fetch_array$result ) )
            {
                if( 
    $row2["category_id"] == $row["photo_category"] )
                {
                    
    $category_list .=<<<__HTML_END
                    <option value="$row2[0]" selected>$row2[1]</option>\n
                    __HTML_END;
                }
                else
                {
        
    $category_list .=<<<__HTML_END
            <option value="
    $row2[0]">$row2[1]</option>\n
        __HTML_END;
                }
            }
            mysql_free_result( 
    $result );
            
    $category_list = '<select name="category_id">'.$category_list.'</select>';
        }
    ?>
    <form name="photo_move" action="edit_photo.php" method="post">
    <b>Move Photo / Update Caption:</b><br />
    Select New Category: <?php echo(
    $category_list); ?><br /><br />
    Update Caption: <input type="text" name="caption" value="<?php echo(
    $row["photo_caption"]); ?>" /><br />
    <input type="hidden" value="<?php echo(
    $phoid); ?>" name="photo_id" />
    <input type="submit" value="Submit" name="action" />
    </form>
    <br />
    <form name="photo_delete" action="edit_photo.php" method="post">
    <b>Delete Photo:</b><br />
    <input type="hidden" value="<?php echo(
    $phoid); ?>" name="photo_id" />
    <input type="submit" value="Delete This Photo?" name="action" onclick="return confirm('Are you sure you want to do delete 
    this photo?')" />
    </form>
    <a href="admin.php">Back to Administration Page</a>
    <?php
    }
    else
    {
        if( strcasecmp(
    $_POST['action'], "Submit")==0 && !empty( $_POST['category_id'] ) )
        {
            edit_photo(
    $phoid$_POST['caption'], $_POST['category_id']);
        }
        else if( strcasecmp(
    $_POST['action'], "Delete This Photo?")==0 && !empty( $phoid ) )
        {
            delete_photo(
    $phoid);
        }
        else
        {
            echo("Action not understood"); exit;
        }
            echo("Process completed!");
            echo("<br><a href='admin.php'>Back to Administration Page</a>");
    }
    // the functions here
    function edit_photo( 
    $photo_id$new_caption$new_category )
    {
        mysql_query( "UPDATE gallery_photos SET photo_caption='".addslashes( 
    $new_caption )."', photo_category='".addslashes( 
        
    $new_category )."' WHERE photo_id='".addslashes( $photo_id )."'"  );
    }
    function delete_photo(
    $photo_id)
    {
        global 
    $images_dir;
        
    $result = mysql_query("
           SELECT photo_filename
           FROM gallery_photos
           WHERE photo_id = '" . addslashes(
    $photo_id) . "'
        ");
        list(
    $filename) = mysql_fetch_array($result);
        mysql_free_result(
    $result);
        unlink(
    $images_dir . '/' . $filename);
        unlink(
    $images_dir . '/tb_' . $filename);
        mysql_query("
           DELETE FROM gallery_photos
           WHERE photo_id='" . addslashes(
    $photo_id) . "'
        ");
    }
    ?>
    I have not checked or use the code so any errors please say.

  15. #690
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, Spence. When I change the code as mentioned above for edit_photo.php, I am getting an error (Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\pvCom\edit_photo.php on line 53). I am not able to make out where I am going wrong. I am giving the lines where I am getting the error.
    PHP Code:
    <form name="photo_move" action="edit_photo.php" method="post">
    <b>Move Photo / Update Caption:</b><br />
    Select New Category: <?php echo($category_list); ?><br /><br />
    Update Caption: <input type="text" name="caption" value="<?php echo($row["photo_caption"]);?>" /><br /> //Line 53 where I am getting the error.
    <input type="hidden" value="<?php echo($photo_id); ?>" name="photo_id" />
    <input type="submit" value="Submit" name="action" />
    </form>
    If I change only the first lines in my own earlier code by writing
    PHP Code:
    // collect and check the data sent by url is a number
    $photo_id = (int)($_GET['photo_id']);
     
    // Check $photo_id is not empty
    if(!empty($photo_id) ) 
    instead of
    PHP Code:
    if( empty($_POST['action']) ) 
    on clicking edit_photo.php, I get the message, Action not understood.

  16. #691
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Change this:
    PHP Code:
    <?php echo($row["photo_caption"]);?>
    To this:
    PHP Code:
    <?php echo($row['photo_caption']);?>

  17. #692
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I already tried that, and am getting the same error.

  18. #693
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I went through every line in my code trying to spot and rectify the errors. But I am back to square one.
    I am getting the message, Action not understood.
    The following is my present code for edit_code.php
    PHP Code:
    <?php
     
        
    include("config.inc.php");
     
        
    // collect and check the data sent by url is a number
    $photo_id = (int)($_GET['photo_id']);
     
    // Check $photo_id is not empty
    if(!empty($photo_id) )
        {
        
    // Firstly Lets get the Photo ID
     
     
        
    $result mysql_query("SELECT photo_caption,photo_filename,photo_category FROM gallery_photos WHERE 
    photo_id='"
    .addslashes($_POST['photo_id'])."'")
    or die(
    mysql_error());
     
    $nr mysql_num_rows($result);
        if( 
    $nr )
        {
            echo(
    "Photo not found in DB!");
        }
        else
        {           
     
        
    $row mysql_fetch_array$result );
        
    mysql_free_result$result );
        echo(
    "Picture ID: ".$_POST['photo_id']."<br><br>");
        echo(
    "<a href='viewgallery.php?cid=".$row['photo_category']."&pid=".$_POST['photo_id']."'><img 
    src='"
    .$images_dir."/tb_".$row[1]."' border='0' alt='".$row[0]."' /></a>");
        
    // Firstly Lets build the Category List
        
    $result mysql_query"SELECT category_id,category_name FROM gallery_category" );
        while( 
    $row2 mysql_fetch_array$result ) )
        {
            if( 
    $row2["category_id"] == $row["photo_category"] )
            {
    $category_list .=<<<__HTML_END
        <option value="$row2[0]" selected>$row2[1]</option>\n
    __HTML_END;
            }
            else
            {
    $category_list .=<<<__HTML_END
        <option value="$row2[0]">$row2[1]</option>\n
    __HTML_END;
            }
        }
        
    mysql_free_result$result );
        
    $category_list '<select name="category_id">'.$category_list.'</select>';
    }
    ?>
    <form name="photo_move" action="edit_photo.php" method="post">
    <b>Move Photo / Update Caption:</b><br />
    Select New Category: <?php echo($category_list); ?><br /><br />
    Update Caption: <input type="text" name="caption" value="<?php echo($row['photo_caption']); ?>" /><br />
    <input type="hidden" value="<?php echo($_POST['photo_id']); ?>" name="photo_id" />
    <input type="submit" value="Submit" name="action" />
    </form>
    <br />
    <form name="photo_delete" action="edit_photo.php" method="post">
    <b>Delete Photo:</b><br />
    <input type="hidden" value="<?php echo($_POST['photo_id']); ?>" name="photo_id" />
    <input type="submit" value="Delete This Photo?" name="action" onclick="return confirm('Are you sure you want to do delete 
    this photo?')" />
    </form>
    <a href="admin.php">Back to Administration Page</a>
    <?php
        
    }
        else
        {
            if( 
    strcasecmp($_POST['action'], "Submit")==&& !empty( $_POST['category_id'] ) )
            {
                
    edit_photo($_POST['photo_id'], $_POST['caption'], $_POST['category_id']);
            }
            else if( 
    strcasecmp($_POST['action'], "Delete This Photo?")==&& !empty( $_POST['photo_id'] ) )
            {
                
    delete_photo($_POST['photo_id']);
            }
            else
            {
                echo(
    "Action not understood"); exit;
            }
            echo(
    "Process completed!");
            echo(
    "<br><a href='admin.php'>Back to Administration Page</a>");
        }
    // the functions here
    function edit_photo$photo_id$new_caption$new_category )
    {
    mysql_query"UPDATE gallery_photos SET photo_caption='".addslashes$new_caption )."', photo_category='".addslashes
    $new_category )."' WHERE photo_id='".addslashes$photo_id )."'"  );
    }
    function 
    delete_photo($photo_id)
    {
    global 
    $images_dir;
    $result mysql_query("
       SELECT photo_filename
       FROM gallery_photos
       WHERE photo_id = '" 
    addslashes($photo_id) . "'
    "
    );
    list(
    $filename) = mysql_fetch_array($result);
    mysql_free_result($result);
    unlink($images_dir '/' $filename);
    unlink($images_dir '/tb_' $filename);
    mysql_query("
       DELETE FROM gallery_photos
       WHERE photo_id='" 
    addslashes($photo_id) . "'
    "
    );
    }
    ?>
    I am wondering whether I now need to make changes in my code displaying the photos to be edited.
    I have tried 2 codes for listing the photos to be edited.
    My first code: When I write this code and get the Action not understood message, my url says
    http://127.0.0.1/pvCom/edit_photo.php?photo_id=
    PHP Code:
    <?php
     
        
    include("config.inc.php");
    echo 
    "<p>Click the photo that needs to be edited: " "</p>";
    //Display all photos with a "Edit this photo" link next to each.
    $query "SELECT * FROM gallery_photos";
    $result1 mysql_query($query);
    while (
    $row mysql_fetch_array($result1) ) {
      
    $photo_id $row["photo_id"];
      
    $photo_filename $row["photo_filename"];
    echo(
    "<a href='edit_photo.php?photo_id=".$_row['photo_id']."'><img src='".$images_dir."/tb_".$row[1]."' border='0' 
    alt='"
    .$row[0]."' />Edit this photo</a>");
     
    }
    ?>
    My second code:When I write this code for displaying the photos to be edited and get the Action not understood message, my
    url adress shows http://127.0.0.1/pvCom/edit_photo.php?cid=1&pid= . The correct category id is being called here.
    PHP Code:
     <?php
     
        
    include("config.inc.php");
    echo 
    "<p>Click the photo that needs to be edited: " "</p>";
    //Display all photos with a "Edit this photo" link next to each.
    $query "SELECT * FROM gallery_photos";
    $result1 mysql_query($query);
    while (
    $row mysql_fetch_array($result1) ) {
      
    $photo_id $row["photo_id"];
      
    $photo_filename $row["photo_filename"];
    echo(
    "<a href='edit_photo.php?cid=".$row['photo_category']."&pid=".$_row['photo_id']."'><img src='".$images_dir."/tb_".$row
    [1]."' border='0' alt='".$row[0]."' />Edit this photo</a>");
     
    }
    ?>
    Spence, in the code that you have shown for listing out the photos to be edited, you have not asked for the category id to be called. Isn't that required? I do not understand why the photo id is not being read while the category id is being called when I use the second code for listing the photos.

  19. #694
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    jppp, you forgot to change the line of code:

    From this:
    PHP Code:
    $result mysql_query("SELECT photo_caption,photo_filename,photo_category FROM gallery_photos WHERE 
    photo_id='"
    .addslashes($_POST['photo_id'])."'"
    To this:
    PHP Code:
    $result mysql_query("SELECT photo_caption,photo_filename,photo_category FROM gallery_photos WHERE 
    photo_id='"
    .addslashes($photo_id)."'"
    I have updated and made a couple of changes below for you to copy and paste. I have tested the script and it seems to work. Let me know if you have any more problems.

    PHP Code:
    <?php
     
        
    include("config.inc.php");
     
        
    // collect and check the data sent by url is a number
    $photo_id = (int)($_GET['photo_id']);
     
    // Check $photo_id is not empty
    if(!empty($photo_id) )
        {
        
    // Firstly Lets get the Photo ID
     
     
        
    $result mysql_query("SELECT photo_caption,photo_filename,photo_category FROM gallery_photos WHERE 
    photo_id='"
    .addslashes($photo_id)."'")
    or die(
    mysql_error());
     
    $nr mysql_num_rows($result);
        if( 
    $nr )
        {
            echo(
    "Photo not found in DB!");
        }
        else
        {           
     
        
    $row mysql_fetch_array$result );
        
    mysql_free_result$result );
        echo(
    "Picture ID: ".$_POST['photo_id']."<br><br>");
        echo(
    "<a href='viewgallery.php?cid=".$row['photo_category']."&pid=".$_POST['photo_id']."'><img 
    src='"
    .$images_dir."/tb_".$row[1]."' border='0' alt='".$row[0]."' /></a>");
        
    // Firstly Lets build the Category List
        
    $result mysql_query"SELECT category_id,category_name FROM gallery_category" );
        while( 
    $row2 mysql_fetch_array$result ) )
        {
            if( 
    $row2['category_id'] == $row['photo_category'] )
            {
    $category_list .= '<option value="'.$row2[0].'" selected>'.$row2[1].'</option>\n';
            }
            else
            {
    $category_list .= '<option value="'.$row2[0].'">'.$row2[1].'</option>\n';
            }
        }
        
    mysql_free_result$result );
        
    $category_list '<select name="category_id">'.$category_list.'</select>';
    }
    ?>
    <form name="photo_move" action="edit_photo.php" method="post">
    <b>Move Photo / Update Caption:</b><br />
    Select New Category: <?php echo($category_list); ?><br /><br />
    Update Caption: <input type="text" name="caption" value="<?php echo($row['photo_caption']); ?>" /><br />
    <input type="hidden" value="<?php echo($_POST['photo_id']); ?>" name="photo_id" />
    <input type="submit" value="Submit" name="action" />
    </form>
    <br />
    <form name="photo_delete" action="edit_photo.php" method="post">
    <b>Delete Photo:</b><br />
    <input type="hidden" value="<?php echo($_POST['photo_id']); ?>" name="photo_id" />
    <input type="submit" value="Delete This Photo?" name="action" onclick="return confirm('Are you sure you want to do delete 
    this photo?')" />
    </form>
    <a href="admin.php">Back to Administration Page</a>
    <?php
        
    }
        else
        {
            if( 
    strcasecmp($_POST['action'], "Submit")==&& !empty( $_POST['category_id'] ) )
            {
                
    edit_photo($_POST['photo_id'], $_POST['caption'], $_POST['category_id']);
            }
            else if( 
    strcasecmp($_POST['action'], "Delete This Photo?")==&& !empty( $_POST['photo_id'] ) )
            {
                
    delete_photo($_POST['photo_id']);
            }
            else
            {
                echo(
    "Action not understood"); exit;
            }
            echo(
    "Process completed!");
            echo(
    "<br><a href='admin.php'>Back to Administration Page</a>");
        }
    // the functions here
    function edit_photo$photo_id$new_caption$new_category )
    {
    mysql_query"UPDATE gallery_photos SET photo_caption='".addslashes$new_caption )."', photo_category='".addslashes
    $new_category )."' WHERE photo_id='".addslashes$photo_id )."'"  );
    }
    function 
    delete_photo($photo_id)
    {
    global 
    $images_dir;
    $result mysql_query("
       SELECT photo_filename
       FROM gallery_photos
       WHERE photo_id = '" 
    addslashes($photo_id) . "'
    "
    );
    list(
    $filename) = mysql_fetch_array($result);
    mysql_free_result($result);
    unlink($images_dir '/' $filename);
    unlink($images_dir '/tb_' $filename);
    mysql_query("
       DELETE FROM gallery_photos
       WHERE photo_id='" 
    addslashes($photo_id) . "'
    "
    );
    }
    ?>
    spence

  20. #695
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Spence, I was too busy and could not come back to my PC earlier.
    I did exactly as you said.
    Now, when I click on the Edit this photo link, I am directed to the page containing the thumbnail of the photo to be edited and the menus for updating the photos. When I do so, I am led to the page saying "Process completed" with a link back to the administration page.
    But the problem is that the update is not taking place. When I go to my gallery page, I find the photos intact in the old categories with their old captions. The photo id and category id are being sent, but they are not getting updated.

  21. #696
    SitePoint Guru
    Join Date
    Nov 2002
    Location
    Dubai
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My listeditphoto.php file which displays the list of photos is like this now.
    PHP Code:
    <?php
     
        
    include("config.inc.php");
    echo 
    "<p>Click the photo that needs to be edited: " "</p>";
    //Display all photos with a "Edit this photo" link next to each.
    $query "SELECT * FROM gallery_photos";
    $result1 mysql_query($query);
    while (
    $row mysql_fetch_array($result1) ) {
      
    $photo_id $row["photo_id"];
      
    $photo_filename $row["photo_filename"];
    echo(
    "<a href='edit_photo.php?cid=".$row['photo_category']."&photo_id=$photo_id'><img src='".$images_dir."/tb_".$row[1]."' border='0' alt='".$row[0]."' />Edit this photo</a>");
     
    }
    ?>
    and my edit_photo.php file is like this.
    PHP Code:
    <?php
        
    include("config.inc.php");
        
    // collect and check the data sent by url is a number
    $photo_id = (int)($_GET['photo_id']);
    // Check $photo_id is not empty
    if(!empty($photo_id) )
        {
        
    // Firstly Lets get the Photo ID
     
        
    $result mysql_query("SELECT photo_caption,photo_filename,photo_category FROM gallery_photos WHERE 
    photo_id='"
    .addslashes($photo_id)."'")
    or die(
    mysql_error());
    $nr mysql_num_rows($result);
        if( 
    $nr )
        {
            echo(
    "Photo not found in DB!");
        }
        else
        {           
        
    $row mysql_fetch_array$result );
        
    mysql_free_result$result );
        echo(
    "Picture ID: ".$_POST['photo_id']."<br><br>");
        echo(
    "<a href='viewgallery.php?cid=".$row['photo_category']."&pid=".$_POST['photo_id']."'><img 
    src='"
    .$images_dir."/tb_".$row[1]."' border='0' alt='".$row[0]."' /></a>");
        
    // Firstly Lets build the Category List
        
    $result mysql_query"SELECT category_id,category_name FROM gallery_category" );
        while( 
    $row2 mysql_fetch_array$result ) )
        {
            if( 
    $row2['category_id'] == $row['photo_category'] )
            {
    $category_list .= '<option value="'.$row2[0].'" selected>'.$row2[1].'</option>\n';
            }
            else
            {
    $category_list .= '<option value="'.$row2[0].'">'.$row2[1].'</option>\n';
            }
        }
        
    mysql_free_result$result );
        
    $category_list '<select name="category_id">'.$category_list.'</select>';
    }
    ?>
    <form name="photo_move" action="edit_photo.php" method="post">
    <b>Move Photo / Update Caption:</b><br />
    Select New Category: <?php echo($category_list); ?><br /><br />
    Update Caption: <input type="text" name="caption" value="<?php echo($row['photo_caption']); ?>" /><br />
    <input type="hidden" value="<?php echo($_POST['photo_id']); ?>" name="photo_id" />
    <input type="submit" value="Submit" name="action" />
    </form>
    <br />
    <form name="photo_delete" action="edit_photo.php" method="post">
    <b>Delete Photo:</b><br />
    <input type="hidden" value="<?php echo($_POST['photo_id']); ?>" name="photo_id" />
    <input type="submit" value="Delete This Photo?" name="action" onclick="return confirm('Are you sure you want to do delete 
    this photo?')" />
    </form>
    <a href="admin.php">Back to Administration Page</a>
    <?php
        
    }
        else
        {
            if( 
    strcasecmp($_POST['action'], "Submit")==&& !empty( $_POST['category_id'] ) )
            {
                
    edit_photo($_POST['photo_id'], $_POST['caption'], $_POST['category_id']);
            }
            else if( 
    strcasecmp($_POST['action'], "Delete This Photo?")==&& !empty( $_POST['photo_id'] ) )
            {
                
    delete_photo($_POST['photo_id']);
            }
            else
            {
                echo(
    "Action not understood"); exit;
            }
            echo(
    "Process completed!");
            echo(
    "<br><a href='admin.php'>Back to Administration Page</a>");
        }
    // the functions here
    function edit_photo$photo_id$new_caption$new_category )
    {
    mysql_query"UPDATE gallery_photos SET photo_caption='".addslashes$new_caption )."', photo_category='".addslashes
    $new_category )."' WHERE photo_id='".addslashes$photo_id )."'"  );
    }
    function 
    delete_photo($photo_id)
    {
    global 
    $images_dir;
    $result mysql_query("
       SELECT photo_filename
       FROM gallery_photos
       WHERE photo_id = '" 
    addslashes($photo_id) . "'
    "
    );
    list(
    $filename) = mysql_fetch_array($result);
    mysql_free_result($result);
    unlink($images_dir '/' $filename);
    unlink($images_dir '/tb_' $filename);
    mysql_query("
       DELETE FROM gallery_photos
       WHERE photo_id='" 
    addslashes($photo_id) . "'
    "
    );
    }
    ?>

  22. #697
    SitePoint Addict
    Join Date
    Jan 2009
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi all

    I've beeen trying to get this tutorial to work for the past 4 days now with little success. I've got the preupload.php to work which takes me to the upload.php page where it says there are photos that are added to the DB, but nothing shows up in the DB.

    I've downloaded the files to work with them but they seem to be slightly differnent from those in the tutorial.

    I know this is really checky but does anyone have working files of this tutorial that I could look at.

    Any help would be greaty appreicated.

  23. #698
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    OK folks, I'm going to run through the tutorial and check it all works and post the code.
    Give me a little bit of time to put it together
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  24. #699
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    righty then.
    The code below works fine. The only thing I would change is the quality of the thumbnail but thats a personal thing really.
    I have added the quality parameter in the upload.php file.

    The Files

    config.inc.php
    Code PHP:
    <?php
     
     $mysql_link = mysql_connect('localhost', 'root', 'password');
     mysql_select_db('sitepoint') or die('Could not select database');
     
     $images_dir = 'photos';
     
    ?>

    preupload.php

    Code PHP:
    <?php
     include 'config.inc.php';
     
     // initialization
     $photo_category_list = '';
     $photo_upload_fields = '';
     $counter = 1;
     
     // If we want more fields, then use, preupload.php?number_of_fields=20
     $number_of_fields = (isset($_GET['number_of_fields'])) ?
       (int)($_GET['number_of_fields']) : 5;
     
     // 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 Image 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>Lets upload Photos</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>
       <!&#8212;Insert the image fields here -->
       $photo_upload_fields
       <tr><td>
         <input type="submit" name="submit"
           value="Add Photos" />
       </td></tr>
     </table>
    </form>
    </body>
    </html>
    __HTML_END;
    ?>

    upload.php

    Code 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'
    					);
     
    	// 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'])."')" 
    					) or die(mysql_error() . 'Photo not uploaded');
     
    				$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
    			      	ImageCopyResized( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1] );
    				}
     
    				// Let's save the thumbnail
    				$function_to_write( $destination_handle, $images_dir."/tb_".$filename, 99 );
    				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;
    ?>

    viewgallery.php

    Code PHP:
    <?php
    	include("config.inc.php");
     
    	// initialization
    	$result_array = array();
    	$counter = 0;
     
    	$cid = (int)($_GET['cid']);
    	$pid = (int)($_GET['pid']);
     
    	// Category Listing
     
    	if( empty($cid) && empty($pid) )
    	{
    		$number_of_categories_in_row = 4;
     
    		$result = mysql_query( "
    			SELECT 
    				  c.category_id
    				, c.category_name
    				, COUNT(photo_id)
    			FROM 
    				gallery_category as c
    			LEFT JOIN 
    				gallery_photos as p 
    			ON 
    				p.photo_category = c.category_id
    			GROUP BY 
    				c.category_id" 
    			);
    		while( $row = mysql_fetch_array( $result ) )
    		{
    			$result_array[] = "<a href='viewgallery.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[2].")";
    		}
    		mysql_free_result( $result );	
     
    		$result_final = "<tr>\n";
     
    		foreach($result_array as $category_link)
    		{
    			if($counter == $number_of_categories_in_row)
    			{	
    				$counter = 1;
    				$result_final .= "\n</tr>\n<tr>\n";
    			}
    			else
    			$counter++;
     
    			$result_final .= "\t<td>".$category_link."</td>\n";
    		}
     
    		if($counter)
    		{
    			if($number_of_categories_in_row-$counter)
    			$result_final .= "\t<td colspan='".($number_of_categories_in_row-$counter)."'>&nbsp;</td>\n";
     
    			$result_final .= "</tr>";
    		}
    	}
     
     
    	// Thumbnail Listing
     
    	else if( $cid && empty( $pid ) )
    	{
    		$number_of_thumbs_in_row = 5;
     
    		$result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'" );
    		$nr = mysql_num_rows( $result );
     
    		if( empty( $nr ) )
    		{
    			$result_final = "\t<tr><td>No Category found</td></tr>\n";
    		}
    		else
    		{
    			while( $row = mysql_fetch_array( $result ) )
    			{
    				$result_array[] = "<a href='viewgallery.php?cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /></a>";
    			}
    			mysql_free_result( $result );	
     
    			$result_final = "<tr>\n";
     
    			foreach($result_array as $thumbnail_link)
    			{
    				if($counter == $number_of_thumbs_in_row)
    				{	
    					$counter = 1;
    					$result_final .= "\n</tr>\n<tr>\n";
    				}
    				else
    				$counter++;
     
    				$result_final .= "\t<td>".$thumbnail_link."</td>\n";
    			}
     
    			if($counter)
    			{
    				if($number_of_photos_in_row-$counter)
    			$result_final .= "\t<td colspan='".($number_of_photos_in_row-$counter)."'>&nbsp;</td>\n";
     
    				$result_final .= "</tr>";
    			}
    		}
    	}
     
    	// Full Size View of Photo
    	else if( $pid )
    	{
    		$result = mysql_query( "SELECT photo_caption,photo_filename FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" );
    		list($photo_caption, $photo_filename) = mysql_fetch_array( $result );
    		$nr = mysql_num_rows( $result );
    		mysql_free_result( $result );	
     
    		if( empty( $nr ) )
    		{
    			$result_final = "\t<tr><td>No Photo found</td></tr>\n";
    		}
    		else
    		{
    			$result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" );
    			list($category_name) = mysql_fetch_array( $result );
    			mysql_free_result( $result );	
     
    			$result_final .= "<tr>\n\t<td>
    						<a href='viewgallery.php'>Categories</a> &gt; 
    						<a href='viewgallery.php?cid=$cid'>$category_name</a></td>\n</tr>\n";
     
    			$result_final .= "<tr>\n\t<td align='center'>
    					<br />
    					<img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' />
    					<br />
    					$photo_caption
    					</td>
    					</tr>";
    		}
    	}
     
    // Final Output
    echo <<<__HTML_END
     
    <html>
    <head>
    	<title>Gallery View</title>
    </head>
    <body>
    <table width='100%' border='0' align='center' style='width: 100%;'>
    $result_final		
    </table>
    </body>
    </html>
     
    __HTML_END;
    ?>

    Copy and pasting the above code will give you a working but basic gallery system.
    Last edited by spikeZ; Jan 7, 2009 at 09:43.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  25. #700
    SitePoint Wizard spence_noodle's Avatar
    Join Date
    Jan 2004
    Location
    uk, Leeds (area)
    Posts
    1,264
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Nice one Spikez, just shows you how still popular this tutorial is.

    Anyway, jppp I'll get back to you, I've been busy. From what I can see it's something to do with these lines:

    PHP Code:
    if( strcasecmp($_POST['action'], "Submit")==&& !empty( $_POST['category_id'] ) )
            {
                
    edit_photo($_POST['photo_id'], $_POST['caption'], $_POST['category_id']);
            } 
    I'll need to check it out later and I'll post what I've come up with, etc...


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
  •