Lassie Posted February 4, 2008 Share Posted February 4, 2008 I have a program which creates a gallery of thumbnail images. Whe selected the selected image is shown. I have this working on my localhost machine but I get the following error on my server. Warning: getimagesize(./images/gallery/) [function.getimagesize]: failed to open stream: Permission denied in W:\www\e_cart19\browse_cats.php on line 54 I have the gd functions enabled and the database connections are fine. Could anyone point me in a direction investigate please. Quote Link to comment https://forums.phpfreaks.com/topic/89398-getimage-size-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 4, 2008 Share Posted February 4, 2008 From the error - "./images/gallery/" That is not a path/filename. It appear like the filename part is missing from the end. Find out what would cause your code to drop the filename. I suspect that your code is dependent on register globals. You would need to post your code if you want help on what it is doing. Quote Link to comment https://forums.phpfreaks.com/topic/89398-getimage-size-error/#findComment-457785 Share on other sites More sharing options...
Lassie Posted February 4, 2008 Author Share Posted February 4, 2008 Thanks for coming back The code is as follows. The file is appended as $mainImage. <?php include ('book_sc_fns.php'); // The shopping cart needs sessions, so start one session_start(); do_html_header(); //define number of cols in the table define('COLS',3); //set maxium number of records per page define('SHOWMAX',9); //connect to db //$connection = db_connect(); include("misc.inc"); $connection = mysql_connect($host,$user,$password) or die ("$connection:".mysql_error($connection)); $db = mysql_select_db($database,$connection) or die ("$db:".mysql_error($connection)); //prepare sql to get total records $getTotal = 'SELECT COUNT(*)FROM categories'; //sunbit query and store results as $totalPix $total = mysql_query($getTotal); $row = mysql_fetch_row($total); $totalPix = $row[0]; //set the current page $curPage = isset($_GET['curPage']) ? $_GET['curPage'] : 0; // calculate the start row of the subset $startRow = $curPage * SHOWMAX; $query = "SELECT * from categories LIMIT $startRow, ".SHOWMAX; $result = mysql_query($query); if (!$result) return false; $num_cats = mysql_num_rows($result); if ($num_cats ==0) return false; $row = mysql_fetch_assoc($result); // get the name and caption for the main image $mainImage = $row['filename']; // get the name for the main image if(isset($_GET['image'])) { $mainImage = $_GET['image']; } else{ $mainImage = $row['filename']; } // get the dimensions of the main image $imageSize = getimagesize('./images/gallery/'.$mainImage); ?> <h1>Browse E-Book Categories</h1> <p id="picCount">Displaying <?php echo $startRow+1; if ($startRow+1 < $totalPix) { echo ' to '; if ($startRow+SHOWMAX < $totalPix) { echo $startRow+SHOWMAX; } else { echo $totalPix; } } echo " of $totalPix"; ?></p> <div class="float-divider"></div> <div id="gallery"> <table id="thumbs" align="center"> <tr> <!--This row needs to be repeated--> <?php //initialised cell counter outside loop $pos = 0; do { // set caption if thumbnail is same as main image if ($row['filename'] == $mainImage) { $caption = $row['cat_description']; $cat_id=$row['cat_id']; $about=$row['about']; } ?> <td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?image=<?php echo $row['filename']; ?>&curPage=<?php echo $curPage; ?>"><img src="images/thumbs/<?php echo $row['filename']; ?>" alt="<?php echo $row['cat_description']; ?>" width="80" height="54" /></a></td> <td><h1><?php echo $row['cat_description'];?></h1></td> <?php $row = mysql_fetch_assoc($result); //increment counter after next row extracted $pos++; // if at end of row and records remain, insert tags if ($pos%COLS === 0 && is_array($row)) { echo '</tr><tr>'; } } while($row); // end of loop // new loop to fill in final row while ($pos%COLS) { echo '<td> </td>'; $pos++; } ?> </tr> <!-- Navigation link needs to go here --> <td><?php // create a back link if current page greater than 0 if ($curPage > 0) { echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage-1).'">< Prev</a>'; } // otherwise leave the cell empty else { echo ' '; } ?> </td> <?php // pad the final row with empty cells if more than 3 columns if (COLS-3 > 0) { for ($i = 0; $i < COLS-3; $i++) { echo '<td> </td>'; } } ?> <td> <?php // create a forwards link if more records exist if ($startRow+SHOWMAX < $totalPix) { echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage+1).'">Next ></a>'; } // otherwise leave the cell empty else { echo ' '; } ?> </td> </tr> </table> <div id="main_image"> <table align="center"> <tr> <td><p><?php echo $caption; ?></p></td> <tr> <td> <p><img src="images/gallery/<?php echo $mainImage; ?>" alt="<?php echo $caption; ?>" <?php echo $imageSize[3]; ?> /></p> </td> <td><?php echo $about;?></td> </tr></table> </div> </div><!--End Div Gallery--> <?php $url='show_cat.php?cat_id='.$cat_id; $title='View all the E-Books in this Category'; do_html_url($url, $title); echo '<br />'; do_html_footer(); exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/89398-getimage-size-error/#findComment-457806 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.