January 22, 201016 yr Hi I'm trying to make a gallery in php, the pictures are in MySQL database but when I View it in the browsers the pictures don't display just the alt or the red x. Can anyone help I'm new to php. Do I have to enable something on the server?
January 22, 201016 yr Hi I'm trying to make a gallery in php, the pictures are in MySQL database but when I View it in the browsers the pictures don't display just the alt or the red x. Can anyone help I'm new to php. Do I have to enable something on the server? how are the images stored in the database, also can you show the code in html that loads the picture. Pat
January 22, 201016 yr Avoid using BINARY/BLOB types to store data in the database, the overheads are pretty high and shared hosting usualyl won't allow you to.
January 24, 201016 yr Hi I'm trying to make a gallery in php, the pictures are in MySQL database but when I View it in the browsers the pictures don't display just the alt or the red x. Can anyone help I'm new to php. Do I have to enable something on the server? Best way to store images is just use a VARCHAR and store the exact path of the images atleast i find it useful this way.And to display them use a while loop to loop through each one<_<
January 24, 201016 yr Another fairly simple way: <?php // Define a specific format for the image. $imageFormat = '<li><img src="%s" alt="%s" width="125" height="125" /></li>'; // Settings $images = NULL; $imagePath = 'static/images/'; // Run $files = glob($imagePath.'*.png'); $total = count($files); // Check if it's found any. if ($total != 0) { foreach($files as $file) { // Path info. $info = pathinfo($file); // Build up image string. $images.= vsprintf($imageFormat,array($imagePath.$info['basename'],$info['filename'])); } // The result. echo '<ul class="gallery">'.$images.'</ul>'; } else { echo 'No images!'; }
January 25, 201016 yr Author I stored the images on the database using VARCHAR. This is the HTML code : <h1><br /> Tanzania Photo Gallery </h1> <p> </p> <div id="pictureWrapper"> <div id="mainpic"><img <?php echo getDims($row_getPictures['image'],'orginal/gallery_php/main_pics/');?> src="<?php echo $row_getPictures['../../gallary/image']; ?>" alt="<?php echo $row_getPictures['caption']; ?>" /></div> <p id="picCaption"><?php echo $row_getPictures['caption']; ?></p> </div> <div id="thumbnails"> <table> <tr> <?php do { // horizontal looper version 3 ?> <td><a href="orginal/gallery_php/main_pics/<?php echo $row_getPictures['image']; ?>"onclick="showImage(this);return false;"><img src="orginal/gallery_php/thumbnails/<?php echo $row_getPictures['image']; ?>" border="0" <?php echo getDims($row_getPictures['image'],'orginal/gallery_php/thumbnails/'); ?> /></a></td> <?php $row_getPictures = mysql_fetch_assoc($getPictures); if (!isset($nested_getPictures)) { $nested_getPictures= 1; } if (isset($row_getPictures) && is_array($row_getPictures) && $nested_getPictures++ % 3==0) { echo "</tr><tr>"; } } while ($row_getPictures); //end horizontal looper version 3 ?> </tr> </table> <table id="pageNav"> <tr> <td width="23%" align="center"><?php if ($pageNum_getPictures > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_getPictures=%d%s", $currentPage, 0, $queryString_getPictures); ?>"><img src="First.gif" border=0></a> <?php } // Show if not first page ?> </td> <td width="31%" align="center"><?php if ($pageNum_getPictures > 0) { // Show if not first page ?> <a href="<?php printf("%s?pageNum_getPictures=%d%s", $currentPage, max(0, $pageNum_getPictures - 1), $queryString_getPictures); ?>"><img src="Previous.gif" border=0></a> <?php } // Show if not first page ?> </td> <td width="23%" align="center"><?php if ($pageNum_getPictures < $totalPages_getPictures) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_getPictures=%d%s", $currentPage, min($totalPages_getPictures, $pageNum_getPictures + 1), $queryString_getPictures); ?>"><img src="Next.gif" border=0></a> <?php } // Show if not last page ?> </td> <td width="23%" align="center"><?php if ($pageNum_getPictures < $totalPages_getPictures) { // Show if not last page ?> <a href="<?php printf("%s?pageNum_getPictures=%d%s", $currentPage, $totalPages_getPictures, $queryString_getPictures); ?>"><img src="Last.gif" border=0></a> <?php } // Show if not last page ?> </td> </tr> </table> <p><?php include('message.txt'); ?> </p> </div> Edited January 26, 201016 yr by Sam G added [code] tags
January 25, 201016 yr Author I tried using BLOB and loading the images on to see if was because I was using VARCHAR but I still get no Pictures just the captions.
January 25, 201016 yr In the html you posted their doesnt seem to be any connection to the database, or did you just not post that bit
January 26, 201016 yr Author Yes the ($row_getPictures ['image'], is the connection to the database, getPictures is the name of the recordset and 'orginal/gallery_php/main_pics/') is the path to the photos. I'm using dreamweaver 8 I inserted the picture and selected data source and selected the recordset and ['image'] which is the name of the column the photos are in, in the database. <img <?php echo getDims($row_getPictures['image'],'orginal/gallery_php/main_pics/');?> src="<?php echo $row_getPictures['../../gallary/image']; ?>" alt="<?php echo $row_getPictures['caption']; ?>" /></div> <p id="picCaption"><?php echo $row_getPictures['caption']; ?></p>
January 26, 201016 yr Yes the ($row_getPictures ['image'], is the connection to the database, getPictures is the name of the recordset and 'orginal/gallery_php/main_pics/') is the path to the photos. I'm using dreamweaver 8 I inserted the picture and selected data source and selected the recordset and ['image'] which is the name of the column the photos are in, in the database. <img <?php echo getDims($row_getPictures['image'],'orginal/gallery_php/main_pics/');?> src="<?php echo $row_getPictures['../../gallary/image']; ?>" alt="<?php echo $row_getPictures['caption']; ?>" /></div> <p id="picCaption"><?php echo $row_getPictures['caption']; ?></p> try this.. <img <?php echo getDims($row_getPictures['image'],'orginal/gallery_php/main_pics/');?> src="orginal/gallery_php/main_pics/<?php echo $row_getPictures['image']; ?>" alt="<?php echo $row_getPictures['caption']; ?>" /></div> <p id="picCaption"><?php echo $row_getPictures['caption']; ?></p> as if $row_getPictures['image']; pull through the name of the file (i.e. myfile.jpg) you just need to prepend it onto the path. original/gallery_php/main_pics/<?php echo $row_getPictures['image']; ?> .. But of course thats me doing it blindly.
Create an account or sign in to comment