Jump to content

php?ID=0


Supremezzy

Recommended Posts

Hi i am some problems with my website.

 

Whenever I create a gallery within my websites admin panel, the php?ID=0, and whenever I create multiple galleries, it also links to the same URL.

I don't know what the problem is and hopefully someone can help.

Here is the gallery PHP code.

 

     

<?php
          $GalleryID=$_GET['ID'];
//      $sql_rsGallery = "SELECT * FROM tGallery WHERE GalleryID=1";
      $sql_rsGallery = "SELECT * FROM tGallery WHERE GalleryID=$GalleryID";
      $rsGallery = mysql_query($sql_rsGallery, $conDB) or die(mysql_error());
      $totalRows_rsGallery = mysql_num_rows($rsGallery);
      if ($totalRows_rsGallery > 0) {
                $row_rsGallery = mysql_fetch_assoc($rsGallery);
            echo $row_rsGallery['GalleryTitle3'];
                echo "<br /><br /><br />";
                $GalleryFolder = $row_rsGallery['GalleryFolder'];
                foreach (new DirectoryIterator('gallery/'.$GalleryFolder.'/small/') as $file) {
                  // if the file is not this file, and does not start with a '.' or '..',
                  // then store it for later display
                  $FirstChar = $file->getFilename();
                  $FirstChar = $FirstChar[0];
                  if ( ($FirstChar != ".") && (pathinfo($file, PATHINFO_EXTENSION) == "jpg") && (!$file->isDot()) && ($file->getFilename() != basename($_SERVER['PHP_SELF'])) ) {
                        // if the element is a directory -> dont use it
                        $arrFiles[] = ($file->isDir()) ? $file="" : $file->getFilename();
                  }
                }
                //print_r($arrFiles);
                asort($arrFiles);
                foreach ($arrFiles as $PictureName) {
                  if ($GalleryFolder == "dancing") { // Gallery dancing are Portrait, so width and height are different
                        ?>
                        <a href="gallery/<?php echo $row_rsGallery['GalleryFolder']; ?>/big/<?php echo $PictureName; ?>" rel="lightbox[salsa1]" title=""><img src="gallery/<?php echo $row_rsGallery['GalleryFolder']; ?>/small/<?php echo $PictureName; ?>" title="Click to enlarge" alt="" width="100" height="150" /></a>
                        <?php
                  }
                  else {
                        ?>
                        <a href="gallery/<?php echo $row_rsGallery['GalleryFolder']; ?>/big/<?php echo $PictureName; ?>" rel="lightbox[salsa1]" title="<a href="gallery/<?php echo $row_rsGallery['GalleryFolder']; ?>/download/<?php echo $PictureName; ?>" target="_blank">Download this picture »</a>"><img src="gallery/<?php echo $row_rsGallery['GalleryFolder']; ?>/small/<?php echo $PictureName; ?>" title="Click to enlarge" alt="" width="133" height="100" /></a>
                        <?php
                  }
                }
          }
          mysql_free_result($rsGallery);
          ?>

Link to comment
Share on other sites

Do yourself a favor and use some checks for your GET values before querying DB.  Adding a default $GalleryID will also prevent a fatal error when no GET value is present.

if (isset($_GET['ID'])){
 $GalleryID=mysql_real_escape_string($_GET['ID']);
}
else{
$GalleryID=1;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.