Jump to content

Nrees87

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Posts posted by Nrees87

  1. Hi guys, I have a gallery page, that has been working fine for several months now. But all of a sudden when I try and add a new image with the following PHP code:

    [code]$imgquery = mysql_query("INSERT INTO mlc_gallery (ItemID,Title,Description,File,Category)". "VALUES ('NULL', '" . $capt . "', '" . $descr . "','". $_FILES['file']['name'] ."', '" . $gallerycat . "')") or die(mysql_error());[/code]

    I get the following error:

    [code]Duplicate entry '127' for key 1[/code]

    The table layout is as follows(information shown is from export table option in MySQL Admin):

    [code]CREATE TABLE `mlc_gallery` (
      `ItemID` tinyint(4) NOT NULL auto_increment,
      `Title` varchar(50) NOT NULL default '',
      `Description` text NOT NULL,
      `File` text NOT NULL,
      `Category` tinyint(1) NOT NULL default '0',
      PRIMARY KEY  (`ItemID`)
    ) TYPE=MyISAM PACK_KEYS=0 AUTO_INCREMENT=127 ;[/code]

    I have tried changing the AUTO_INCREMENT value to 128 to overcome this problem, but it stays on 127.

    Any help is greatly appreciated.

    Nathan Rees
  2. Thanks Hooker, helped a great deal. Problem solved - take a look [a href=\"http://www.mlcfreeriders.co.uk/gallery.php\" target=\"_blank\"]http://www.mlcfreeriders.co.uk/gallery.php[/a]

    Thanks,
    Nathan
  3. Hi there guys (and gals of course Wink ). I'm currently creating a website for a friend of mine. I've written a gallery page (really simple one) which just retrieves data from a MySQL database. What I'm trying to do now is to get it to automatically split the gallery into X amount of pages, each page with 20 images on it. For some reason I can't get my head around it.

    So far I have this:
    [code]
    function new_display_gallery($img_dir,$cat,$page)
    {  
        $query = "SELECT * FROM `mlc_gallery` WHERE `Category` = '" . $cat . "' ORDER BY `ItemID` ASC;";
        $result = mysql_query($query) or die(mysql_error());
        
        if(mysql_num_rows($result) == "0")
        {
            echo '<p><i>This Gallery is empty</i></p>';
        }
        else
        {
          
          $g_size = mysql_num_rows($result);
          //5 colums * 4 rows = 20 imgs per page
          $pages = ceil($g_size / 20);
          if($page == "1")
          {
              $query = "SELECT * FROM `mlc_gallery` WHERE `Category` = '" . $cat . "' LIMIT 1,20" ;
              $res = mysql_query($query) or die(mysql_error());
            $r = mysql_fetch_assoc($query);
          }
          elseif($page == "2")
          {
              $query = "SELECT * FROM `mlc_gallery` WHERE `Category` = '" . $cat . "' LIMIT 21,20" ;
              $res = mysql_query($query) or die(mysql_error());
            $r = mysql_fetch_assoc($query);
          }
          elseif($page == "3")
          {
              $query = "SELECT * FROM `mlc_gallery` WHERE `Category` = '" . $cat . "' LIMIT 41,20" ;
              $res = mysql_query($query) or die(mysql_error());
            $r = mysql_fetch_assoc($query);
          }
          echo '<div id="main" style="width: 512px;">';
          echo '<table id="display_thumbnails" cellpadding="0" cellspacing="0">';
          while($r_num <= 6)
          {
              echo '<tr>';
              while($c_num <= 6)
              {
                echo "<td><img src='./gallery/mlc/" . $r['File']. "' /></td>";
                $c_num++;
            }
            echo '</tr>';
            $r_num++;
          }
          echo '</table>';
          echo '</div>';
          echo '<div class="navigate_images"><p>Page ' . $page . ' of '    . $pages . '</p></div>';
        }
    }
    [/code]

    It's driving me crazy because I've hit a complete mental block of how to do this.

    Can anyone provide any help/ideas or possibly some example code?

    Thanks in advance,
    Nathan Rees.
×
×
  • 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.