SitePoint Sponsor

User Tag List

Page 31 of 31 FirstFirst ... 212728293031
Results 751 to 767 of 767
  1. #751
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My last question on this i hope :$

    What I want to do is be able to add the year when I add the category, so I want it to add the gallery name and the year ( this is so the categories can appear in an ordered fashion )

    How can I do this, I've tried various methods and tried implementing code from other insert forms I've used but no use...

    This is the code I'm talking about:


    Code:
    <?php
    error_reporting(0);
    session_start();
    if(!session_is_registered('users')){
    header("location:login.php");
    }
    ?>
    <?php
    
        include("config.inc.php");
    
    
    
        if( empty($_POST['action']) )
    
        {
    
    
    
        $result = mysql_query( "SELECT category_id,category_name,Year FROM gallery_category" );
    
        while( $row = mysql_fetch_array( $result ) )
    
        {
    
    $category_list .=<<<__HTML_END
    
    
        <option value="$row[0]">$row[1]</option>\n
    
    __HTML_END;
        }
    
        mysql_free_result( $result );    
    
    
    
        $category_list = '<select name="categoryid">'.$category_list.'</select>';
    
    ?>
    
    
    <div id="maincontent">
    
    <div class="hsection1">
    <div class="title">Add Category:</div>
    <form name="add_category" action="mcategory.php" method="post">
    
    
    
    
    
    Name: <input type="text" name="cname" /> 
    
    <!-- add category year -->
    Year: <input type="text" name="year" /> 
    
    
    
    
    
    <input type="submit" value="add" name="action" />
    
    </form>
    </div>
    
    
    <div class="hsection1">
    <div class="title">Edit Category:</div>
    <form name="edit_category" action="mcategory.php" method="post">
    
    New Name: <input type="text" name="cname" />
    
    
    <?php echo($category_list); ?>
    
    <input type="submit" value="edit" name="action" />
    
    
    
    </form>
    </div>
    
    
    
    <div class="hsection1">
    <div class="title">Delete Category:</div>
    <form name="delete_category" action="mcategory.php" method="post">
    
    
    <?php echo($category_list); ?>
    
    <input type="submit" value="delete" name="action" />
    
    
    
    </form>
    </div>
    
    
    </div>
    
    
    
    
    
    <?php
    
        }
    
        else
    
        {
    
            if( strcasecmp($_POST['action'], "add")==0 && !empty( $_POST['cname'] ) )
    
            {
    
                add_category($_POST['cname']);
    			
    			
    	
    		
    		}
    
            else if( strcasecmp($_POST['action'], "edit")==0 && !empty( $_POST['cname'] ) && !empty( $_POST['categoryid'] ) )
    
            {
    
                edit_category($_POST['categoryid'], $_POST['cname']);
    
            }
    
            else if( strcasecmp($_POST['action'], "delete")==0 && !empty( $_POST['categoryid'] ) )
    
            {
    
                delete_category($_POST['categoryid']);
    
            }
    
            else
    
            {
    
                echo("Action not understood"); exit;
    
            }
    
    
    
            echo("Process completed!");
    
        }
    
    
    
    
    
    // the functions here
    
    
    
    function edit_category($category_id, $new_name) 
    
    { 
    
     mysql_query(" 
    
       UPDATE gallery_category SET 
    
         category_name = '" . addslashes($new_name) . "' 
    
       WHERE category_id = '" . addslashes($category_id) . "'"); 
    
    }
    
    function add_category($category_name) 
    
    { 
    
     mysql_query(" 
    
       INSERT INTO gallery_category ( 
    
        category_name
    
       ) VALUES ( 
    
         '" . addslashes($category_name) . "' 
    
       )"); 
     
    
    
    }
    
    function delete_category($category_id) 
    
    { 
    
     global $images_dir;
    
    
    
     $result = mysql_query(" 
    
       SELECT photo_filename 
    
       FROM gallery_photo 
    
       WHERE photo_category='" . addslashes($category_id) . "'");   
    
     while ($row = @mysql_fetch_array($result)) { 
    
       unlink($images_dir . '/' . $row[0]); 
    
     } 
    
    
    
     mysql_query(" 
    
       DELETE FROM gallery_photo 
    
       WHERE photo_category='" . addslashes($category_id) . "'"); 
    
    
    
     mysql_query(" 
    
       DELETE FROM gallery_category 
    
       WHERE category_id='" . addslashes($category_id) . "'"); 
    
    }
    
    ?>

  2. #752
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok scratch that, i've got it working now

  3. #753
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi everyone, i've read the whole thread its really good as i have everything working well.

    I even have the next and back links for the thumbnails and the full size images but i need to have the lightbox effect for the full size images is this possible??

    Thanks

  4. #754
    SitePoint Member
    Join Date
    Sep 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey everyone a love all the features u guys ahve added to the gallery and have gotten most of the ones i like working. the only thing i am having problems with right now is the subcategories. i got my database setup like spence_noodle's when he posted his database scheme. i also tried getting his code working with it but for some reason i couldnt. im still pertty new to php and mysql. would anyone that has this working would they be able to post the viewgallery.php script and the uploading/ preuploading script. thanks heres my code right now mabe i am jsut missing something. only got the view gallery script so far having started the other ones

    Code:
    <?php
    
    	include("gallery/config.php");
    
    
    
    	// initialization
    
    	$result_array = array();
    
    	$counter = 0;
    
    
    
    	$cid = (int)($_GET['cid']);
    
    	$pid = (int)($_GET['pid']);
    
    
    
    	// Category Listing
    
    
    
     $number_of_categories_in_row = 1;
     
     if( empty($cid) && empty($pid) )
     {
     
     $cat = mysql_query( "SELECT c.category_id, c.category_name, c.category_parent, c.category_des, COUNT(p.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 ORDER BY c.category_des ASC" );
     
         while( $row = mysql_fetch_array( $cat ) )
         {
             if($row[2] == 0)
             {
                 $cat_array[] = "<font face='Verdana, Arial, Helvetica, sans-serif' size='1'><a href='cat_user.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[4].")</font><br />";
                 }
                 
                 if($row[2] > 0)
                 {
                 $subresult = mysql_query("SELECT category_id,category_name,category_parent,category_des FROM gallery_category WHERE category_name='".$row[1]."' ORDER BY category_des ASC");
                 
                     while( $sub_result = mysql_fetch_array( $subresult ) )
                     {
                         if ($sub_result[2] !='')
                         {
                         $line1 = explode('/', $sub_result[3]);
                         
                         $line2 = implode(', ', $line1);
                         
                         $words1 = preg_replace('/\s+/', '', $line2);
                         
                         $words2 = str_replace(',', ' ', $words1);
                         
                         $level = substr_count($words2," ");
                         
                         if($level == 1)
                         {
                         $add = str_repeat('&nbsp;', 0);
                         }
                         
                         if($level == 2)
                         {
                         $add = str_repeat('&nbsp;', 2);
                         }
                         
                         if($level == 3)
                         {
                         $add = str_repeat('&nbsp;', 4);
                         }
                         
                         $subcat = mysql_query( "SELECT COUNT(p.photo_id)
                         FROM gallery_category as c
                         LEFT JOIN gallery_photos as p ON p.photo_category = '".$sub_result[0]."'
                         GROUP BY c.category_id ORDER BY c.category_name ASC" );
                         $sub_cat = mysql_fetch_array( $subcat );
                         
                         $cat_array[] = "<font face='Verdana, Arial, Helvetica, sans-serif' size='1'>".$add."|-<a href='cat_user.php?cid=".$row[0]."'>".$sub_result[1]."</a> "."(".$sub_cat[0].")</font><br />";
                         }
                     }
                 }
             }
             mysql_free_result( $cat );
             mysql_free_result( $subresult );
             
             foreach($cat_array as $category_link)
             {
             if($counter == $number_of_categories_in_row)
             {
             $counter = 1;
             }
             else
             $counter++;
         
             $cat_final .= "$category_link";
             }
     
     }
     //Final result
     echo "$cat_final";
    
    	// Thumbnail Listing
    
    
    
    	else if( $cid && empty( $pid ) )
    
    	{
    
    		$number_of_thumbs_in_row = 4;
    
    		
    
    		// If current page number, use it 
    
    		// if not, set one! 
    
    
    
    		if(!isset($_GET['page'])){ 
    
        		$page = 1; 
    
    		} else { 
    
        		$page = $_GET['page']; 
    
    		} 
    
    
    
    		// Define the number of results per page 
    
    		$max_results = 12; 
    
    		
    
    		// Figure out the limit for the query based 
    
    		// on the current page number. 
    
    		$from = (($page * $max_results) - $max_results); 
    
    		
    
    		$result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."' LIMIT $from, $max_results"); 
    
    				
    
    		$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='gallery.php?cid=$cid&pid=".$row[0]."'><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /><br />".$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_thumbs_in_row-$counter)."'>&nbsp;</td>\n";
    
    
    
    				$result_final .= "</tr>\n";
    
    				
    
    // Figure out the total number of results in DB: 
    
    $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM gallery_photos WHERE photo_category=".addslashes($cid).""),0); 
    
    
    
    // Figure out the total number of pages. Always round up using ceil() 
    
    $total_pages = ceil($total_results / $max_results); 
    
    
    
    if ($total_pages >1)
    
    {  // build links if more than one page
    
    
    
    
    
    // Build Page Number Hyperlinks 
    
    $result_final .=  "<tr><td colspan='".$number_of_thumbs_in_row."' class='tcat'>\nPages&nbsp;(".$total_pages."):&nbsp;"; 
    
    
    
    
    
    // Build Previous Link 
    
    if($page > 1){ 
    
        $prev = ($page - 1); 
    
        $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$prev\" title='Previous Page'>&lt;&lt;</a>"; 
    
    } 
    
    
    
    for($i = 1; $i <= $total_pages; $i++){ 
    
        if(($page) == $i){ 
    
            $result_final .= "&nbsp;[$i]"; 
    
            } else { 
    
                $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$i\" title='Page ".$i."'>$i</a>"; 
    
        } 
    
    } 
    
    
    
    // Build Next Link 
    
    if($page < $total_pages){ 
    
        $next = ($page + 1); 
    
        $result_final .=  "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$next\" title='Next Page'>&gt;&gt;</a>"; 
    
    } 
    
    $result_final .=  "\n</td></tr>"; 
    
    
    
    }
    
    else
    
    {
    
    $result_final .=  "\n";
    
    }			
    
    }
    
    }
    
    }
    
    
    
      // 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 );    
    
    
    
            //fill pid_array with sorted pids in current category
    
            $result = mysql_query( "SELECT photo_id FROM gallery_photos WHERE photo_category='".addslashes($cid)."' ORDER BY photo_id" );
    
            $ct = mysql_num_rows( $result );    
    
            while ($row = mysql_fetch_array($result)) {
    
                $pid_array[] = $row[0];
    
                 }
    
            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=gallery.php>Albums</a> &gt; 
    
                            <a href=gallery.php?cid=$cid'>$category_name</a><br><br></td>\n</tr>\n";
    
                
    
                // display previous and next links if more than one photo
    
                if ($ct > 1) {
    
                      $key = array_search($pid, $pid_array);
    
                      $prev = $key - 1;
    
                      if ($prev < 0) $prev = $ct - 1;
    
                      $next = $key + 1;
    
                      if ($next == $ct) $next = 0;
    
                      $result_final .= "<tr><td colspan='10'><center>";
    
                      $result_final .= "<a href=gallery.php?cid=$cid&pid=".$pid_array[$prev]."'>Previous</a>&nbsp;&nbsp;&nbsp;";
    
                     $result_final .= "(".($key+1)." / ".$ct.")&nbsp;&nbsp;&nbsp;";
    
                      $result_final .= "<a href=gallery.php?cid=$cid&pid=".$pid_array[$next]."'>Next</a>";
    
                     $result_final .= "</center></td></tr>";
    
                }
    
                            
    
                $result_final .= "<tr>\n\t<td align='center'>
    
                        <img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' width='500' />
    
                        <br />
    
                        $photo_caption
    
                        </td>
    
                        </tr>";
    
            }
    
        } 
    
    
    
    
    // Final Output
    
    echo <<<__HTML_END
    
    
    
    <html>
    
    <head>
    
    	<title>Gallery View</title>
    
    
    </head>
    
    <body>
    
    <table width='80%' border='0' align='center' style='width: 80%;'>
    
    $result_final		
    
    </table>
    
    </body>
    
    </html>
    
    
    
    __HTML_END;
    
    ?>
    with the code like this i get this error "
    Parse error: syntax error, unexpected T_ELSE in /var/www/gallery.php on line 103"

    the block around line 103 is
    Code:
             foreach($cat_array as $category_link)
             {
             if($counter == $number_of_categories_in_row)
             {
             $counter = 1;
             }
             else
             $counter++;
         
             $cat_final .= "$category_link";
             }
     
     }
    i think there is probly even more errors here but im not sure
    im not sure what i am doing worng here but any help with this would be great. thanks in advance

  5. #755
    SitePoint Member
    Join Date
    Nov 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    Hello, i would like to place a link for each thumbnail in the gallery that links to the edit photo page by photo_id. I have succeeded in placing the links, however when the link is clicked it references the first photo_id only in the database for all thumbnails. Please could you tell me where i am going wrong?

    //Below is the script

    <?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='gallery.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[2].")";
    }
    mysql_free_result( $result );

    $result_final = "\n";

    foreach($result_array as $category_link)
    {
    if($counter == $number_of_categories_in_row)
    {
    $counter = 1;
    $result_final .= "\n";
    }
    else
    $counter++;

    $result_final .= "\t".$category_link."\n";
    }

    if($counter)
    {
    if($number_of_categories_in_row-$counter)
    $result_final .= "\t".($number_of_categories_in_row-$counter)."\n";

    $result_final .= "";
    }
    }


    // Thumbnail Listing

    else if( $cid && empty( $pid ) )
    {
    $number_of_thumbs_in_row = 4;

    if(!isset($_GET['page'])){
    $page = 1;
    } else {
    $page = $_GET['page'];
    }

    // Define the number of results per page
    $max_results = 12;

    // Figure out the limit for the query based
    // on the current page number.
    $from = (($page * $max_results) - $max_results);
    // Full Size View of Photo
    $result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."' ORDER BY photo_id DESC LIMIT $from, $max_results");
    $nr = mysql_num_rows( $result );


    if( empty( $nr ) )
    {
    $result_final = "\t No Category found \n";
    }
    else
    {
    while( $row = mysql_fetch_array( $result ) )
    {

    $result_array[] = "<a href='gallery2.php?cid=$cid&pid=".$row[0]."' onclick=\"return popup(this, 'notes')\"><img src='".
    $images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /></a>";
    }
    mysql_free_result( $result );

    $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 );

    $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"];
    $result_final = "<tr>";

    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>
    <table><tr><td colspan=\"2\">".$thumbnail_link."</td></tr></table>
    <p><a href='edit_photo.php?photo_id=".$row['photo_id']."'>Edit Photo</a></p></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>";


    // Figure out the total number of results in DB:
    $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM gallery_photos WHERE photo_category=".addslashes($cid).""),0);

    // Figure out the total number of pages. Always round up using ceil()
    $total_pages = ceil($total_results / $max_results);

    if ($total_pages >1)
    { // build links if more than one page


    // Build Page Number Hyperlinks
    $result_final .= "<tr><td colspan='".$number_of_thumbs_in_row."'>Showing Page: ".$page.' of '.$total_pages."<br>";


    // Build Previous Link
    if($page > 1){
    $prev = ($page - 1);
    $result_final .= "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$prev\" title='Previous Page'>&lt;&lt; Prev</a>";
    }

    for($i = 1; $i <= $total_pages; $i++){
    if(($page) == $i){
    $result_final .= "&nbsp;[$i]";
    } else {
    $result_final .= "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$i\" title='Page ".$i."'>$i</a>";
    }
    }

    // Build Next Link
    if($page < $total_pages){
    $next = ($page + 1);
    $result_final .= "\n<a href=\"".$_SERVER['PHP_SELF']."?cid=$cid&page=$next\" title='Next Page'>Next &gt;&gt;</a>";
    }
    $result_final .= "\n</td></tr>";

    }
    else
    {
    $result_final .= "\n";
    }
    }
    }
    }

    else if( $pid )
    {

    $result = mysql_query( "SELECT photo_caption,photo_filename FROM gallery_photos WHERE photo_id='".addslashes($pid)."'ORDER BY photo_id DESC" );
    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>
    </td>\n</tr>\n";

    $result_final .= "<tr>\n\t<td align='center'>


    <table><tr><td colspan=\"2\"><a href='gallery.php?cid=$cid'><img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' /></a></td></tr><tr>
    <td>Before</td><td>After</td></tr></table>
    <br />
    $photo_caption
    $photo_filename
    </td>
    </tr>
    ";
    }
    }

    // Final Output
    echo <<<__HTML_END

    <table>
    <tr><td>
    $result_final
    </td></tr>
    </table>


    __HTML_END;

    ?>

  6. #756
    SitePoint Member
    Join Date
    Dec 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi everyone, thanks for the awesome efforts in this thread over the years it has helped me to get an idea of how to set up an image gallery.

    My issue is that I have developed a site on my laptop and can use all of the functionality that I am still developing, ie upload the images, page scrolling etc. Unfortunately when I go to another Pc and type in the link to the pre-upload page and attempt to upload an image to the gallery I am returned with the error File 1 is not a photo.

    This appears to correspond to the code in the upload.php file:

    Code:
    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
    			{
    The issue appears to be permissions based?

    I have tried to amend the directory to give all permissions 777, and tried many combinations (default at 755). I have applied this to the portfolio folder and the photos sub folder. When i do this i then may receive an issue with server permissions...

    Does anyone have any idea why I can upload all of my files from my laptop but not from any other pc?

  7. #757
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, this is a great script to have. I have a couple questions though...

    After closely following the tutorial and writing up the code, it seems that I can't get the photo_category_list to work in any of the pages. Because of this, I am unable to post an uploaded photo onto the viewgallery.php page.... Also something to note, is that the photo category's aren't even showing up in the preupload.php page when I go to upload a photo.

    Here is the code I am using for my preupload.php page:
    PHP 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>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>
    <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;
    ?>

    What am I doing wrong? Why aren't the photo categories appearing on the preupload.php page? Thanks for any and all help on this.

  8. #758
    SitePoint Enthusiast
    Join Date
    Apr 2010
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Need updated one workin on current php n mysql versions

  9. #759
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Adding this error_reporting(0); to the top of config.inc.php makes it work like it's supposed to...

    Why the Heredoc syntax? why not just code it normally.

  10. #760
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,445
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    Turning off error reporting does NOT fix problems, much better to fix the code so it doesn't error instead if you can.
    And IMHO heredoc syntax is normal.

  11. #761
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there, ive been following this gallery tutorial and have the gallery working fine, but I also wanted to integrate the watermarking code into it that Infizi added here: http://www.sitepoint.com/forums/show...&postcount=501

    Straight off the bat that didnt work for me due to this erroring as $watermark_image being empty:
    Code PHP:
    $w = getimagesize($watermark_image)

    I changed this to $watermark and has got rid of the error, but whenever i submit a photo to the gallery it doesnt include the watermark on the image, its as if this watermark code ive added doesnt exist.

    Here is the watermark code to add as per Infizi:

    Code PHP:
    // Store the orignal file
    copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$filename);
     
    // Watermark the original file
    //////////////////////////////// WATERMARK SCRIPT ////////////////////////////////////////
    ///////// Courtesy of Rob Guard ([url]www.infizi.com[/url] // [email]rob@infizi.com[/email]) and Sitepoint /////////
    // Requires GD Image Lib 1.8++ //
    $my_watermark = "watermark.png"; // Must be PNG-24 Format - Create in photoshop using a trasparent background - set the image layer trasparency to around 40%
     
    $margin = 5; // px margin around watermark
    $my_image = $images_dir."/".$filename;
     
    // Get the watermark image, load it in to a variable and get its size.
    $watermark = imagecreatefrompng($my_watermark);
    $w = getimagesize($watermark_image);
     
    // Create the read and write functions for the new image
    $function_suffix = $gd_function_suffix[$filetype];
    $Create = 'ImageCreateFrom' . $function_suffix;
    $Save = 'Image' . $function_suffix;
     
    // Load in Image to be watermarked
    $image = $Create($my_image);
    $image_size = getimagesize($my_image);
     
    // Total width - watermark width - margin gives co-ordinates for the watermark.
    $dest_x = $size[0] - $w[0] - $margin;
    $dest_y = $size[1] - $w[1] - $margin;
     
    // Merge the images
    imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $w[0], $w[1]);
     
    // Save $image to $my_image
    $Save($image, $my_image);
     
    //Destroy TMP files
    imagedestroy($image);
    imagedestroy($watermark);
     
    ////////////////////////////////  END WATERMARK   ////////////////////////////////////////

    Can anyone see what is up with this? would really appreciate your help as its the last hurdle i have before this website is finished.

    Many Thanks

  12. #762
    SitePoint Enthusiast
    Join Date
    May 2010
    Location
    UK
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was wondering whether there's any likelihood of somebody at Sitepoint doing a new tutorial, along the same lines as the original but reflecting current versions (and standards) of PHP, mySQL, etc? It would be greatly appreciated! :-)

    Alex

  13. #763
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I just read through all 31 pages of this and suggest the title of the original tutorial should be renamed to Build An Automated PHP Gallery System In YEARS!

  14. #764
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,445
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    Well, if you started when this article was published - Aug 7, 2003 - and it's taken you this long to get through 31 pages, maybe at least for you it should be renamed Build An Automated PHP Gallery System In LIFETIMES!

  15. #765
    SitePoint Enthusiast
    Join Date
    May 2010
    Location
    UK
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, I'm guessing a new tutorial is a way off then?! :-P

  16. #766
    SitePoint Member
    Join Date
    Jan 2008
    Location
    pakistan
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I used this article to create a gallery for a website I,m working on but I ran into a problem the loop to upload the images only runs for a maximum 6 times . I removed the option to select the number of images and fixed it to fifteen.

  17. #767
    SitePoint Enthusiast
    Join Date
    May 2010
    Location
    UK
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Aah, okay, great thanks for the tip! It's come at the right time as I'm just doing an Estate Agents' website atm :-)

    A new tutorial from SitePoint HQ would be fab though too.

    Alex


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
  •